Skip to content

Instantly share code, notes, and snippets.

@BioQwer
Created October 22, 2014 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BioQwer/92c90faea589ac153920 to your computer and use it in GitHub Desktop.
Save BioQwer/92c90faea589ac153920 to your computer and use it in GitHub Desktop.
validation with Help @pattern
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