struct Athena::Validator::Constraints::GroupSequence


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

  property name : String

  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

In this case, it'll validate the name and 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.

NOTE The default group is not allowed as part of a group sequence.

NOTE Calling validate with a group in the sequence, such as strict, will 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 default group.

See AVD::Constraints::GroupSequence::Provider for a way to dynamically determine the sequence an object should use.

Defined in:



Instance Method Summary

Constructor Detail

def : Array(String)) #

[View source]
def : Array(String | Array(String))) #

[View source]

Instance Method Detail

def groups : Array(String | Array(String)) #

[View source]