Open ilopmar opened 5 years ago
The introspection API currently does not support annotation metadata on generic type arguments. Until this is supported we cannot support this use case. This is not in scope for 1.2.0 however.
You can however implement this with:
@Valid
@NotBlank
private List<String> myList;
I have a similar issue with javax @Size
annotation
Miconaut version: 3.9.4
@Valid
@Size(max = 2) List<@Valid @NotBlank @Size(max = 10) String> stringList;
The problem with above snipped is the outer limit of maximum size of list i.e. 2, is getting applied on inside string items and it's not allowing more than 2 characters as strings
The validation was rewritten in Micronaut 4
Steps to Reproduce
Create a POJO:
Create a test:
Expected Behaviour
The test should pass
Actual Behaviour
The test fails:
Environment Information
Example Application
https://github.com/ilopmar/mn-bean-validator-data-class. Run
MyPojoConstraintsSpec
testAdditional info
It seems that the issue is
@Introspected
doesn't add the necessary information onmyList
field. So when retrieving the constraints here: https://github.com/micronaut-projects/micronaut-core/blob/40d2f1f11f763b0a20f2e5d245a4f8b9daf84087/validation/src/main/java/io/micronaut/validation/validator/DefaultValidator.java#L129-L130 the list is empty.Also, annotation
myList
with@Valid
triggers some validation but again, the information metadata is not found.