Closed javier-godoy closed 4 months ago
In order torun all the validators, you need to copy-paste the following code.
List<Validator<T>> validators = ((ValidationSupport<T>) this).getValidators(DeletionValidator.class); List<ErrorDescription> errors = validators.stream().flatMap(val->val.validate(entity).stream()).collect(Collectors.toList()); if (!errors.isEmpty()) { throw new DeletionValidationException(errors); }
There should be a utility method for that purpose. For instance, in ValidationSupport add:
ValidationSupport
List<ErrorDescription> validate(Class<Validator<T>> validatorType, T t) { List<Validator<T>> validators = ((ValidationSupport<T>) this).getValidators(validatorType); return validators.stream().flatMap(val -> val.validate(t).stream()).collect(Collectors.toList()); }
In order torun all the validators, you need to copy-paste the following code.
There should be a utility method for that purpose. For instance, in
ValidationSupport
add: