1

For the address field, instead of creating 3 parameters

String addr1;
String addr2;
String addr3;

I have listed it as,

List<String> addressLines;

Now the issue is how I can add min, max length of string fields. If it's one at a time, I can add @Max(40)

One way I can think is by adding String to a class, and make a list of that class and there validate. But, it's just a workaround.

Satish Patro
  • 3,645
  • 2
  • 27
  • 53
  • 2
    Does this answer your question? [Adding @NotNull or Pattern constraints on List](https://stackoverflow.com/questions/22233512/adding-notnull-or-pattern-constraints-on-liststring) replacing the `@NotNull` to your `@Max(40)` – Tschallacka Mar 19 '20 at 12:10

1 Answers1

3

You can annotate the type parameter:

List<@Max(40) String> addressLines;
Gustavo Passini
  • 2,348
  • 19
  • 25