Applying the same constraint annotation twice to one field silently produces no adapter. The
processor warns, and validation then throws at runtime.
Reproduction
@Valid
record Two(@Size(min = 1) @Size(max = 5) List<String> x) {}
Validator.instance().validate(new Two(List.of()));
Compile output
warning: No Constraints Defined
record Two(@Size(min = 1) @Size(max = 5) List<String> x) {}
No TwoValidationAdapter is generated.
Runtime
java.lang.IllegalArgumentException: No ValidationAdapter for class v.V2$Same
at io.avaje.validation.core.CoreAdapterBuilder.buildForType(CoreAdapterBuilder.java:83)
at io.avaje.validation.core.CoreAdapterBuilder.build(CoreAdapterBuilder.java:60)
at io.avaje.validation.core.DValidator.adapter(DValidator.java:151)
Notes
- A single
@Size on the same field works and reports the violation.
@NotBlank @Size on a String works; repeating @NotBlank @NotBlank does not even compile
(NotBlank is not a repeatable annotation interface), so @Size is the case where repetition is
accepted by the compiler but not handled by the generator.
- Hibernate Validator 9.1.2 validates the repeated form (
@Size(min=1) @Size(max=5) on a List)
and reports the violation.
Expected
Either support repeated constraints on the same element, or reject them at build time with an error
rather than emitting a warning and no adapter (the failure currently surfaces only at runtime).
Applying the same constraint annotation twice to one field silently produces no adapter. The
processor warns, and validation then throws at runtime.
Reproduction
Compile output
No
TwoValidationAdapteris generated.Runtime
Notes
@Sizeon the same field works and reports the violation.@NotBlank @Sizeon aStringworks; repeating@NotBlank @NotBlankdoes not even compile(
NotBlank is not a repeatable annotation interface), so@Sizeis the case where repetition isaccepted by the compiler but not handled by the generator.
@Size(min=1) @Size(max=5)on aList)and reports the violation.
Expected
Either support repeated constraints on the same element, or reject them at build time with an error
rather than emitting a warning and no adapter (the failure currently surfaces only at runtime).