danielgtaylor/huma

The validation of format:"email" is not perfect.

Closed this issue · 3 comments

Email string json:"email" doc:"Email of the user" format:"email"

Validation was added and tested as above.
abc -> deny
abc@ -> deny
abc@a -> allow
abc@a. -> deny
acb@a.bc -> allow

Here I think it's strange that abc@a passes validation.

Is this a valid email by rfc 5322?

I'm confused by the email verification standards that are different from usual.

These are indeed valid email addresses. You can use your own validation logic to further narrow down the emails you wish to accept.

See https://en.wikipedia.org/wiki/Email_address#Examples, specifically "admin@example"; or even https://stackoverflow.com/questions/20573488/why-does-html5-form-validation-allow-emails-without-a-dot for information.

ICANN banned dotless email address, but they do remain syntactically correct (e.g., user@localhost with localhost being a valid domain).

Thank you very much