I have around 500 fields where I need to check values coming for the fields from json in spring rest endpoint are having valid values
ex:
Class Customer {
long id;
String gender; // acceptable values: MALE || FEMALE
int validated; // acceptable values: 0 || 1
String plan;// acceptable values: PLAN1 || PLAN2 || PLAN3 || PLAN4
}
it will be harder to write a custom method to check each field, is there any generic approach where we dont need to write method validations for each field or class.
I have tried this Java String validation using enum values and annotation but this is not throwing error when the value is not in the acceptable values. Basically it should be throwing exception if value is other than acceptable value