0

Using Spring Boot with hibernate. I have something like this in the poko

@Email
private String email;

These example inputs:

  • fakeemail
  • fakeemail@

I get the following error, which is expected:

email: not a well-formed email address.

However for this input:

  • fakeemail@a

This is considered ok. Does Hibernate not care about the domain? (.com, .io, .company)?

PS: Using as of this date, the newest version here: https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator/6.0.9.Final

Franz
  • 19
  • 8

2 Answers2

1

fakeemail@a can be considered a valid domain if you're sending an email to a local host named a.

In general, in the email validation, we accept more things that what would be strictly valid to avoid reporting errors for valid cases.

If you want to be stricter, you can add a regexp requiring a dot in the domain using the regexp attribute of the @Email annotation.

Guillaume Smet
  • 9,921
  • 22
  • 29
0

As you can see on Wikipedia

Valid email addresses:

  • simple@example.com
  • very.common@example.com
  • disposable.style.email.with+symbol@example.com ...
  • admin@mailserver1 (local domain name with no TLD, although ICANN highly discourages dotless email addresses)

The most commonly seen dotless email address would be localhost (e.g. root@localhost).

However, if you're interested, you can make your own custom @Email annotation

Community
  • 1
  • 1
TwiN
  • 3,554
  • 1
  • 20
  • 31