Skip to content

class Athena::Validator::Constraints::All
inherits Athena::Validator::Constraints::Composite #

Validates each element of an Iterable is valid based on a collection of constraints.


Required Arguments#


Type: Array(AVD::Constraint) | AVD::Constraint

The AVD::Constraint(s) that you want to apply to each element of the underlying iterable.

Optional Arguments#


This constraint does not support a message argument.


Type: Array(String) | String | Nil Default: nil

The validation groups this constraint belongs to. AVD::Constraint::DEFAULT_GROUP is assumed if nil.


Type: Hash(String, String)? Default: nil

Any arbitrary domain-specific data that should be stored with this constraint. The payload is not used by Athena::Validator, but its processing is completely up to you.


class Example
  include AVD::Validatable

  def initialize(@strings : Array(String)); end

  # Assert each string is not blank and is at least 5 characters long.
  getter strings : Array(String)


The annotation approach only supports two levels of nested annotations. Manually wire up the constraint via code if you require more than that.

Class methods#

.new(constraints : Array(AVD::Constraint) | AVD::Constraint, groups : Array(String) | String | Nil = nil, payload : Hash(String, String)? = nil) #

View source


#validated_by : AVD::ConstraintValidator.class #

Returns the AVD::ConstraintValidator.class that should handle validating self.

View source