Skip to content

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.

View source

Methods#

#add_constraint(constraints : Array(AVD::Constraint)) : self#

Adds each of the provided constraints to self.

View source

#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.

View source

#add_getter_constraint(method_name : String, constraint : AVD::Constraint) : self#

Adds the provided constraint to the provided method_name.

View source

#add_property_constraint(property_name : String, constraints : Array(AVD::Constraint)) : self#

Adds each of the provided constraints to the provided property_name.

View source

#add_property_constraint(property_name : String, constraint : AVD::Constraint) : self#

Adds the provided constraint to the provided property_name.

View source

#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.

View source

#class_name : T.class#

View source

#constrained_properties : Array(String)#

Returns an array of the properties who self has constraints defined for.

View source

#default_group : String#

The #class_name based group for self.

View source

#group_sequence : AVD::Constraints::GroupSequence | ::Nil#

The AVD::Constraints::GroupSequence used by self, if any.

View source

#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.

View source

#group_sequence_provider=(active : Bool) : Nil#

View source

#has_property_metadata?(property_name : String) : Bool#

Returns true if self has property metadata for the provided property_name.

View source

#name : String | ::Nil#

View source

#property_metadata(property_name : String) : Array(AVD::Metadata::PropertyMetadataInterface)#

Returns an AVD::Metadata::PropertyMetadataInterface instance for the provided property_name, if any.

View source