abstract class Athena::Validator::Constraints::Composite
Overview
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
Defined in:
constraints/composite.crConstructors
Instance Method Summary
-
#add_implicit_group(group : String) : Nil
Adds the provided group to
#groups
ifself
is in theAVD::Constraint::DEFAULT_GROUP
. - #constraints : Array(AVD::Constraint)
Instance methods inherited from class Athena::Validator::Constraint
add_implicit_group(group : String) : Nil
add_implicit_group,
groups : Array(String)
groups,
groups=(groups : Array(String))
groups=,
message : String
message,
payload : Hash(String, String) | Nil
payload,
validated_by : AVD::ConstraintValidator.class
validated_by
Constructor methods inherited from class Athena::Validator::Constraint
new(message : String, groups : Array(String) | String | Nil = nil, payload : Hash(String, String) | Nil = nil)
new
Class methods inherited from class Athena::Validator::Constraint
error_name(error_code : String) : String
error_name
Constructor Detail
def self.new(constraints : Array(AVD::Constraint) | AVD::Constraint, message : String, groups : Array(String) | String | Nil = nil, payload : Hash(String, String) | Nil = nil)
#
Instance Method Detail
def add_implicit_group(group : String) : Nil
#
Description copied from class Athena::Validator::Constraint
Adds the provided group to #groups
if self
is in the AVD::Constraint::DEFAULT_GROUP
.