I have a simple Input Model that has an Email
property on it. I'm using the EmailAddress
DataAnnotation to validate the input data.
[Required]
[Display(Name = "UserReview_CustomerEmailTitle", ResourceType = typeof(Resources.User.Settings))]
[EmailAddress(ErrorMessageResourceType = typeof(Resources.User.Settings), ErrorMessageResourceName = "UserReview_InvalidEmailMessage")]
public string CustomerEmail { get; set; }
It works perfectly (ie. data is valid) if there are no spaces before/after the input data.
When I have a space at the end of the input text, it fails the validation.
Is there any tricks I can do to TRIM the input data coming in OR tell the EmailAddress validator to ignore prepended/postpended spaces?
EDIT:
I'm open to creating a custom attribute... I can't inherit from the EmailAddress
attribute because it's sealed
(sigh) .. so maybe a regex attribute?