protected void validateModelClass ( Object model ) { final Set < ConstraintViolation < Object > > violations = validator . validate ( model ) ; // in case of an invalid model, we throw a ConstraintViolationException, containing the violations: if ( ! violations . isEmpty ( ) ) { throw new ConstraintViolationException ( new HashSet <> ( violations ) ) ; } }
Generic validator used to identify constraint violations of the given model class .