validateObject method
Every violation of target, including those inside @Valid()
properties; an empty list when it is valid or not @Introspected.
Use it to check an object in code and decide what to do with the
problems. groups selects the constraints, by default those of the
Default group. A group of groupSequences is checked group by
group, stopping at the first group with a violation, and a class's
@GroupSequence replaces its Default group. Throws a
ValidationException when a constraint or group is declared wrongly.
Jakarta's Validator.validate(object, groups...).
// An edit: only the constraints of the OnUpdate group.
final violations = BeanValidator().validateObject(
form,
groups: [OnUpdate],
);
Implementation
List<ConstraintViolation> validateObject(
Object target, {
List<Type> groups = const [],
}) {
final violations = <ConstraintViolation>[];
_inGroups(
groups,
violations,
(groups) =>
_validate(target, target, '', groups, violations, Set.identity()),
);
return violations;
}