class Athena::Validator::ExecutionContext(Root)

Overview

Basic implementation of AVD::ExecutionContextInterface.

Included Modules

Defined in:

execution_context.cr

Constructors

Instance Method Summary

Instance methods inherited from module Athena::Validator::ExecutionContextInterface

add_violation(message : String, code : String, value : _) : Nil
add_violation(message : String, parameters : Hash(String, String) = {} of String => String) : Nil
add_violation(message : String, code : String) : Nil
add_violation
, build_violation(message : String, code : String, value : _) : AVD::Violation::ConstraintViolationBuilderInterface
build_violation(message : String, parameters : Hash(String, String) = {} of String => String) : AVD::Violation::ConstraintViolationBuilderInterface
build_violation(message : String, code : String) : AVD::Violation::ConstraintViolationBuilderInterface
build_violation
, class_name class_name, constraint : AVD::Constraint? constraint, group : String? group, metadata : AVD::Metadata::MetadataInterface? metadata, object object, property_name : String? property_name, property_path : String property_path, root root, validator : AVD::Validator::ValidatorInterface validator, value value, violations : AVD::Violation::ConstraintViolationListInterface violations

Constructor Detail

def self.new(validator : AVD::Validator::ValidatorInterface, root : Root) #

[View source]

Instance Method Detail

def add_violation(message : String, parameters : Hash(String, String) = {} of String => String) : Nil #

Adds a violation with the provided message, and optionally parameters based on the node currently being validated.


[View source]
def add_violation(message : String, code : String) : Nil #

Adds a violation with the provided message and code


[View source]
def add_violation(message : String, code : String, value : _) : Nil #

Adds a violation with the provided message, and code, value parameter.

The provided value is added to the violations' parameters as "{{ value }}".


[View source]
def build_violation(message : String, parameters : Hash(String, String) = {} of String => String) : AVD::Violation::ConstraintViolationBuilderInterface #

Returns an AVD::Violation::ConstraintViolationBuilderInterface with the provided message.

Can be used to add additional information to the AVD::Violation::ConstraintViolationInterface being adding it to self.


[View source]
def build_violation(message : String, code : String) : AVD::Violation::ConstraintViolationBuilderInterface #

Returns an AVD::Violation::ConstraintViolationBuilderInterface with the provided message, and code.


[View source]
def build_violation(message : String, code : String, value : _) : AVD::Violation::ConstraintViolationBuilderInterface #

Returns an AVD::Violation::ConstraintViolationBuilderInterface with the provided message, and code, and value.

The provided value is added to the violations' parameters as "{{ value }}".


[View source]
def class_name #

Returns the class that is currently being validated.


[View source]
def constraint : AVD::Constraint? #

Returns the AVD::Constraint that is currently being validated, if any.


[View source]
def group : String? #

Returns the group that is currently being validated, if any.


[View source]

Returns an AVD::Metadata::MetadataInterface object for the value currently being validated.

This would be an AVD::Metadata::PropertyMetadataInterface if the current value is an object, an AVD::Metadata::GenericMetadata if the current value is a plain value, and an AVD::Metadata::ClassMetadata if the current value value is an entire class.


[View source]
def object #

Returns the object that is currently being validated.


[View source]
def object_container : AVD::Container #

The object that is currently being validated.


[View source]
def property_name : String? #

Returns the property name of the node currently being validated.


[View source]
def property_path(path : String = "") : String #

Returns the path to the property that is currently being validated.

For example, given a Person object that has an Address property; the property path would be empty initially. When the address property is being validated the property_path would be address. When the street property of the related Address object is being validated the property_path would be address.street.

This also works for collections of objects. If the Person object had multiple addresses, the property path when validating the first street of the first address would be addresses[0].street.


[View source]
def root : Root #

Returns the object initially passed to AVD::Validator::ValidatorInterface#validate.


[View source]

Returns a reference to an AVD::Validator::ValidatorInterface that can be used to validate additional constraints as part of another constraint.


[View source]
def value #

Returns the value that is currently being validated.


[View source]

Returns the AVD::Violation::ConstraintViolationInterface instances generated by the validator thus far.


[View source]