can you tell me how to create custom constraint validator which will work for single field and collection as well?
For instance, I have an object Foo which contains the enum of status
public class Foo {
Status status;
}
Status can be of type active
or disabled
. I want to ensure when I use my annotation constraint for some field of type Foo or Collection, constraint check if field/fields have set the status to the required value.
samples:
@StatusCheck(Status.ACTIVE)
public Foo foo;
or
@StatusCheck(Status.ACTIVE)
public List<Foo> foo;
Is possible to do that with a single validator? Or should I make two? Thanks in advice.