java - Collection validation from single validator -


lets have class:

class foo{   @somecustomstringvalidator   string bar; } 

and have

class foo{    list<string> bars; } 

is there way use somehow @somecustomstringvalidator applied on bars collection ?

if using java 8, use latest hibernate validator 5.2 version. there is possible do:

class foo{   @valid   list<@somecustomstringvalidator string> bars; } 

otherwise use class wrapping approach mentioned in answer.

last not least, write custom constraintvalidator<somecustomstringvalidator, collection> , try sharing core validation logic between validator , `constraintvalidator have.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -