I want to validate a string against a set of values using annotations.
What I want is basically this:
@ValidateString(enumClass=com.co.enum)
String dataType;
int maxValue;
int minValue;
int precision;
or
@ValidateString(values={"String","Boolean", "Integer"})
String dataType;
int maxValue;
int minValue;
int precision;
I also want to do some validation on other variables depending upon the value set in dataType:
if (dataType = "String") {
// maxValue, minValue, precision all should be null or zero
}
I can’t think of a way to achieve this by custom annotations.
Somebody please help me.
This is what I did.
Annotation
Validation Class
And i used it like
Now I need to figure out how to implement conditional check
ie. if String then maxValue and minValue should be null or Zero..
Any ideas?