Created
October 22, 2014 20:50
-
-
Save BioQwer/92c90faea589ac153920 to your computer and use it in GitHub Desktop.
validation with Help @pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user.setEmail("eqwqe@ewe.qwe"); | |
ValidatorFactory vf = Validation.buildDefaultValidatorFactory(); | |
Validator validator = vf.getValidator(); | |
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(user); | |
System.out.println(String.format("Кол-во ошибок: %d", | |
constraintViolations.size())); | |
System.out.println("constraintViolations = " + constraintViolations.isEmpty()); | |
for (ConstraintViolation<Object> cv : constraintViolations) | |
System.out.println(String.format("Внимание, ошибка! property: [%s], value: [%s], message: [%s]",cv.getPropertyPath(), cv.getInvalidValue(), cv.getMessage())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment