Skip to content

Commit

Permalink
Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
dstepanov committed Mar 8, 2023
1 parent ef7324f commit 046eb12
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,6 @@ private <R, E> void validateConstrains(DefaultConstraintValidatorContext<R> cont
for (Class<? extends Annotation> constraintType : elementArgument.getAnnotationMetadata().getAnnotationTypesByStereotype(Constraint.class)) {
valueConstraintOnElement(context, leftBean, elementArgument, elementValue, constraintType);
}
context.messageTemplate(context.getMessageTemplate().orElse(null));
}

private <R, E, A extends Annotation> void valueConstraintOnElement(DefaultConstraintValidatorContext<R> context,
Expand Down Expand Up @@ -1086,8 +1085,10 @@ private <R, E, A extends Annotation> void validateConstraint(DefaultConstraintVa
Set<AnnotationValue<A>> constraints,
Class<E> type) {

Class<Object>[] classValues = annotationMetadata.classValues(Constraint.class, "validatedBy");
ConstraintValidator<A, E> validator = constraintValidatorRegistry.findConstraintValidator(constraintType, type).orElse(null);
if (validator == null) {
return;
}
for (AnnotationValue<A> annotationValue : constraints) {
if (validator.isValid(elementValue, annotationValue, context)) {
continue;
Expand All @@ -1097,18 +1098,20 @@ private <R, E, A extends Annotation> void validateConstraint(DefaultConstraintVa
final String message = messageSource.interpolate(messageTemplate, MessageSource.MessageContext.of(variables));
final ConstraintDescriptor<?> constraintDescriptor = new DefaultConstraintDescriptor<>(annotationMetadata, constraintType, annotationValue);

context.overallViolations.add(
new DefaultConstraintViolation<>(
context.getRootBean(),
context.getRootClass(),
leafBean,
elementValue,
message,
messageTemplate,
new PathImpl(context.currentPath), constraintDescriptor,
context.executableParameterValues
)
DefaultConstraintViolation<R> constraintViolation = new DefaultConstraintViolation<>(
context.getRootBean(),
context.getRootClass(),
leafBean,
elementValue,
message,
messageTemplate,
new PathImpl(context.currentPath),
constraintDescriptor,
context.executableParameterValues
);

context.overallViolations.add(constraintViolation);
context.messageTemplate(null);
}
}

Expand Down

0 comments on commit 046eb12

Please sign in to comment.