I have a simple class that has one of its properties as a String array. As per this document, using @Valid on an array, collection etc. will recursively validate each elemen
First... i'm not sure... but @Pattern
only accepts regex
, right? Correct sintax is not:
@Pattern("^[_ A-Za-z0-9]+$") // delete 'regexp='
If this is not the problem you can create a wrapper class with validators in the attributes:
public class Role {
@Pattern(regexp="^[_ A-Za-z0-9]+$")
String adminRole;
//getters and setters
}
Then just need to mark the field @Valid
in your existing object:
@Valid
Role[] defaultAppAdminRoles;