Is it possible to validate whole graph automatically ? By full graph I mean the object that is being validated and all its fields that are beans too.
Or I have to traverse through them manually as shown below ?
Currently I do something like this
Set<ConstraintViolation<OrderProxy>> violationsOrder =
validator.validate(order, Default.class, ClientGroup.class);
Set<ConstraintViolation<OrganizationProxy>> violationsOrg =
validator.validate(order.getSender(), Default.class, ClientGroup.class);
Set<ConstraintViolation<PersonProxy>> violationsPerson =
validator.validate(order.getSender().getPerson(),
Default.class, ClientGroup.class);
You can annotate any fields that you want validated with
@Validand when validating your main object, it will also validate the fields.This works for example:
You would need to call
to get all violations (also those for the fields). You would then have to parse the causes using
getPropertyPath()to get the exact validation source, if you need it.