javax validation OneOf constraint

2.3k views Asked by At

Is there an annotation in javax validation, so it should constraint that value is one of predefined values. Example

@OneOf(values = "12-14m, 16m, 18m")
private String size;
2

There are 2 answers

0
linarkou On

If you are using hibernate-validator, you can declare new annotation using @ConstraintComposition. This is a good example here.