0

I am writing JSR validation for following inputs.

@JsonProperty(value = "state")
@NotEmpty
private String state;

@JsonProperty(value = "zipValue")
@NotEmpty
@Zip
private String zip;

@JsonProperty(value = "countryName")
@NotEmpty
@CountryAddress
private String countryName;

I am getting inputs from 2 countries. Hence state list and zip code format of countries are different.I want to validate both zip and state in the CountryAddress annotation itself.Could someone help me on this.?

kiran
  • 1
  • 4

1 Answers1

0

You can use class level constraints to validate field combination of the form. Just introduce a new validation and assign it to the class rather than fields.

See here or here

Community
  • 1
  • 1
StanislavL
  • 56,971
  • 9
  • 68
  • 98