- Tag br in appsettings

- Attribute per controllo validità email
This commit is contained in:
2026-01-27 13:47:10 +01:00
parent d9512bab0f
commit 4022fd9ed4
7 changed files with 48 additions and 15 deletions

View File

@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
using System.Text.RegularExpressions;
namespace StandManager.Utils;
public class EmailCheckAttribute : ValidationAttribute
{
protected override ValidationResult? IsValid(object? value, ValidationContext validationContext)
{
var str = value as string;
if (string.IsNullOrEmpty(str)) return ValidationResult.Success;
if (!Regex.IsMatch(str, "^[\\w-\\.\\+]+@([\\w-]+\\.)+[\\w-]{2,}$"))
{
return new ValidationResult(ErrorMessage ?? "Inserire un indirizzo Email valido");
}
return ValidationResult.Success;
}
}