Running sleep restrictions individually?

Is it possible to check a string with a sleeping constraint without having to write a special class for it? For example, if I just want to check whether a given String is an email, can this be checked as a one-time test without writing a full class and checking this restriction on a specific property of the class?

+4
source share
1 answer

You can annotate a property with @Email in an entity class. You can read the documentation at this link: http://docs.jboss.org/ejb3/app-server/HibernateAnnotations/api/org/hibernate/validator/Email.html

Edited by:

String email = "email@test.com";
EmailValidator validator = new EmailValidator();
validator.isValid(email, null);

"isValid" true, .

, !

+4

Source: https://habr.com/ru/post/1530341/


All Articles