A bean class with multiple fields. When checking, if A is empty, check B, otherwise do not check B. And I need to set the message according to different checks.
I have many such validations, can hibernate validator be easily implemented?
Now I write like this
public class Order
{
private String a;
private String b;
//.... other fields
}
public class Validation
{
public void valid(Order order) throws Exception
{
if (order.getA().isEmpty())
{
if (order.getB().isEmpty())
{
throw new Exception("xxx message ");
}
}
//....
}
}