Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is this angular email validation valid?

If you go here, and try to input me@mail, you will see that the directive says that the email field is valid. Why is that?

like image 966
Geo Avatar asked Feb 16 '14 11:02

Geo


People also ask

Is valid email Angular?

Angular Email validation with EmailValidator EmailValidator is a built-in email validator directive in Angular. It adds the email validator to controls marked with the email attribute. You can use it to perform the verification effectively.

Is email validation in Angular 4 can be achieved using email validator?

Email can be validated using Angular PatternValidator directive with a regex. If pattern does not match, we will get validation error. In this way we can define custom email validation. For PatternValidator we need to use pattern attribute with ngModel , formControl , formControlName .

What is the use of NG valid?

ng-valid The field content is valid. ng-invalid The field content is not valid. ng-valid-key One key for each validation. Example: ng-valid-required , useful when there are more than one thing that must be validated.

How do I make sure my email is valid in HTML?

The best way to "validate" an email addresses is to simply have them type it twice and run a Regex check that gives a WARNING to the user that it doesn't look like a valid email address if it does not match the pattern, and asks the user to double check.


2 Answers

Domains do not need to have a dot in them. What about localhost, e.g.?

root@localhost is a perfectly valid email address. And if you give a name to your system (let's say, mail), then root@mail is valid as well. And if you also have a user me, then me@mail finally is valid, too.

like image 174
Golo Roden Avatar answered Nov 15 '22 09:11

Golo Roden


http://en.wikipedia.org/wiki/Email_address

This wikipedia article explains thoroughly what constitutes a valid email address.

As you can see, many valid emails look very scary indeed, and probably don't pass many of the web's lesser validators.

In your case, the domain part of the email address (everything after the @), doesn't necessarily have a top-level domain. or perhaps it's entirely only a top level domain (i.e. postbox@com is valid)

like image 37
Rodik Avatar answered Nov 15 '22 10:11

Rodik