问题
I am using Castle Validators on my model. I have an EmailAddress property defined like so:
[ValidateEmail]
public string EmailAddress { get; set; }
The problem is that the regex (?) that the ValidateEmail attribute uses is incorrect. For instance, if I put in an email address like foo@foo.com, it validates correctly, but if I put in an address like foo+1@foo.com, it says it is not valid.
I realize that I can just use the ValidateRegExp attribute with my own regex, but if possible, I'd prefer to use what's already built in to the system.
So is there some way to "fix" the ValidateEmail attribute?
回答1:
Please get the latest build from the build server, this was fixed a couple of weeks ago.
回答2:
Given that the Castle project is open-source, grab the source and fix it yourself. Then submit the patch back to the project.
The project maintainers will appreciate it (normally; YMMV) and the project gets stronger.
来源:https://stackoverflow.com/questions/1281092/castle-validateemail-attribute-fails-on-plus-sign