Hi @Guillermo Perez ,
You could custom EmailAddress attribute like below:
public class CustomEmailAddress : DataTypeAttribute
{
public CustomEmailAddress()
: base(DataType.EmailAddress)
{
}
public override bool IsValid(object value)
{
if(value==null || String.IsNullOrEmpty(value.ToString()))
{
return true;
}
var flag = new EmailAddressAttribute().IsValid(value.ToString());
if (!flag)
{
return false;
}
else
{
return true;
}
}
}
Model:
public class ExampleModel
{
[CustomEmailAddress(ErrorMessage = "Please provide a valid E-mail Address.")]
public string Email { get; set; }
}
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best Regards,
Rena