Skip to content

struct Athena::Validator::Constraints::GroupSequence
inherits Struct #

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.


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


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.

Class methods#

.new(groups : Array(String)) #

View source

.new(groups : Array(String | Array(String))) #

View source


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

View source