class Athena::Validator::Metadata::ClassMetadata(T)
inherits Reference
#
Represents metadata associated with an AVD::Validatable
instance.
self
is lazily initialized and cached at the class level.
Includes metadata about the class; such as its name, constraints, etc.
Included modules
Athena::Validator::Metadata::GenericMetadata
Constructors#
.build : self
#
Builds self
, auto registering any annotation based annotations on T
,
as well as those registered via T.load_metadata
.
Methods#
#add_constraint(constraints : Array(AVD::Constraint)) : self
#
Adds each of the provided constraints to self
.
#add_constraint(constraint : AVD::Constraint) : self
#
Adds the provided constraint to self
's #constraints
array.
Sets #cascading_strategy
to AVD::Metadata::CascadingStrategy::Cascade
if the constraint is AVD::Constraints::Valid
.
Also adds the #class_name
based group via AVD::Constraint#add_implicit_group
.
#add_getter_constraint(method_name : String, constraint : AVD::Constraint) : self
#
Adds the provided constraint to the provided method_name.
#add_property_constraint(property_name : String, constraints : Array(AVD::Constraint)) : self
#
Adds each of the provided constraints to the provided property_name.
#add_property_constraint(property_name : String, constraint : AVD::Constraint) : self
#
Adds the provided constraint to the provided property_name.
#add_property_constraints(property_hash : Hash(String, AVD::Constraint | Array(AVD::Constraint))) : self
#
Adds a hash of constraints to self
, where the keys represent the property names, and the value
is the constraint/array of constraints to add.
#constrained_properties : Array(String)
#
Returns an array of the properties who self
has constraints defined for.
#group_sequence : AVD::Constraints::GroupSequence | ::Nil
#
The AVD::Constraints::GroupSequence
used by self
, if any.
#group_sequence=(sequence : Array(String) | AVD::Constraints::GroupSequence) : self
#
Sets the AVD::Constraints::GroupSequence
that should be used for self
.
Raises an AVD::Exception::InvalidArgument
if self
is an AVD::Constraints::GroupSequence::Provider
,
the sequence contains AVD::Constraint::DEFAULT_GROUP
,
or the #class_name
based group is missing.
#group_sequence_provider=(active : Bool) : Nil
#
Denotes self
as a AVD::Constraints::GroupSequence::Provider
.
#has_property_metadata?(property_name : String) : Bool
#
Returns true
if self
has property metadata for the provided property_name.
#property_metadata(property_name : String) : Array(AVD::Metadata::PropertyMetadataInterface)
#
Returns an AVD::Metadata::PropertyMetadataInterface
instance for the provided property_name, if any.