Skip to content

abstract class Athena::Validator::Constraints::Composite
inherits Athena::Validator::Constraint #

A constraint composed of other constraints. handles normalizing the groups of the nested constraints, via the following algorithm:

  • If groups are passed explicitly to the composite constraint, but not to the nested constraints, the options of the composite constraint are copied to the nested constraints
  • If groups are passed explicitly to the nested constraints, but not to the composite constraint, the groups of all nested constraints are merged and used as groups for the composite constraint
  • If groups are passed explicitly to both the composite and its nested constraints, the groups of the nested constraints must be a subset of the groups of the composite constraint.

NOTE: You most likely want to use AVD::Constraints::Compound instead of this type.

Direct known subclasses

Athena::Validator::Constraints::All Athena::Validator::Constraints::AtLeastOneOf Athena::Validator::Constraints::Compound Athena::Validator::Constraints::Sequentially

Class methods#

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

View source


#add_implicit_group(group : String) : Nil #

Adds the provided group to #groups if self is in the AVD::Constraint::DEFAULT_GROUP.

View source

#constraints : Array(AVD::Constraint) #

View source