class Athena::Validator::Metadata::ClassMetadata(T)

Overview

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

Defined in:

metadata/class_metadata.cr

Constructors

Instance Method Summary

Instance methods inherited from module Athena::Validator::Metadata::GenericMetadata

add_constraint(constraint : AVD::Constraint) : AVD::Metadata::GenericMetadata add_constraint, add_constraints(constraints : Array(AVD::Constraint)) : AVD::Metadata::GenericMetadata add_constraints, cascading_strategy : AVD::Metadata::CascadingStrategy cascading_strategy, constraints : Array(AVD::Constraint) constraints, find_constraints(group : String) : Array(AVD::Constraint) find_constraints

Instance methods inherited from module Athena::Validator::Metadata::MetadataInterface

cascading_strategy : AVD::Metadata::CascadingStrategy cascading_strategy, constraints : Array(AVD::Constraint) constraints, find_constraints(group : String) : Array(AVD::Constraint) find_constraints

Constructor Detail

def self.build : self #

Builds self, auto registering any annotation based annotations on T, as well as those registered via T.load_metadata.


[View source]
def self.new #

[View source]

Instance Method Detail

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

Adds each of the provided constraints to self.


[View source]
def 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]
def add_getter_constraint(method_name : String, constraint : AVD::Constraint) : self #

Adds the provided constraint to the provided method_name.


[View source]
def add_property_constraint(property_name : String, constraints : Array(AVD::Constraint)) : self #

Adds each of the provided constraints to the provided property_name.


[View source]
def add_property_constraint(property_name : String, constraint : AVD::Constraint) : self #

Adds the provided constraint to the provided property_name.


[View source]
def 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]
def class_name : T.class #

[View source]
def constrained_properties : Array(String) #

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


[View source]
def default_group : String #

The #class_name based group for self.


[View source]
def group_sequence : AVD::Constraints::GroupSequence | Nil #

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


[View source]
def group_sequence=(sequence : Array(String) | AVD::Constraints::GroupSequence) : self #

Sets the AVD::Constraints::GroupSequence that should be used for self.

Raises an ArgumentError 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]
def group_sequence_provider=(active : Bool) : Nil #

[View source]
def has_property_metadata?(property_name : String) : Bool #

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


[View source]
def name : String | Nil #

[View source]
def property_metadata(property_name : String) : Array(AVD::Metadata::PropertyMetadataInterface) #

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


[View source]