1
votes

I know that if I want validate String as a number with length 6 I can write following:

@Pattern(regexp="[\\d]{6}"
String stringToValidate;

But what should I do If I have List<String> stringsToValidate ?

Is there way to reuse out of the box mechanism?

P.S.

I know that I can write own annotation and implement own validator but I want to reuse out of the box functionality.

1

1 Answers

0
votes

I do not see a way to use an existing constraint. Here is a list of the built in JSR303 constraints and the hibernate extensions http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#section-builtin-constraints

I think writing a custom constraint is your best bet.