Allows validating your
AVD::Constraint@validation-groups in steps.
I.e. only continue to the next group if all constraints in the first group are valid.
@[Assert::GroupSequence("User", "strict")] class User include AVD::Validatable @[Assert::NotBlank] property name : String @[Assert::NotBlank] property password : String def initialize(@name : String, @password : String); end @[Assert::IsTrue(message: "Your password cannot be the same as your name.", groups: "strict")] def is_safe_password? : Bool @name != @password end end
In this case, it'll validate the
password properties are not blank before validating they are not the same.
If either property is blank, the
is_safe_password? validation will be skipped.
default group is not allowed as part of a group sequence.
validate with a group in the sequence, such as
cause violations to ONLY use that group and not all groups within the sequence.
This is because the group sequence is now referred to as the
AVD::Constraints::GroupSequence::Provider for a way to dynamically determine the sequence an object should use.