EmailAddressAttribute doesn't check email domain
Hello, I use the EmailAddressAttribute to check a valid Email stirng, but I've got a validation when a bad email address is given to the method.
var test = new EmailAddressAttribute().IsValid("testUser@test");
This code return true.
I use the EmailAddressAttribute
Are you referring to this? https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.emailaddressattribute(v=vs.110).aspx
Just wanted to understand the exact .NET class you are referring to.
Weirdly, testUser@test looks like it's a valid email address. And if you create an email machine call "test" on your local network, you should have no trouble sending email to it.
Email addresses are one of the more convoluted specs. Looking at RFC 2822, testUser@test is an "addr-spec" (section 3.4.1). An addr-spec is a local-part @ domain. The domain in turn is a dot-atom defined in section 3.2.4 and consists of all "atom" chars plus dots (periods) which are allowed but are not required. If you look a the spec, BTW, the [CFWS] is white space and the 1* notation means "one or more" (from RFC 2234, section 3.6)
(I used to work for one of the teams that handled email; even URLs are easier to get right than email addresses).
Thanks @PeterSmithRedmond, that could explain my "issue". I found it strange that you could specify with a enum the type of address you want to check. it could be a simple way to distinguish internal vs external address.
@davidsh Yes it is.