class Athena::Validator::Spec::MockValidator

Overview

A spec implementation of AVD::Validator::ValidatorInterface.

Allows settings the violations that should be returned. Defaults to no violations.

Included Modules

Defined in:

spec.cr

Constructors

Instance Method Summary

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

in_context(context : AVD::ExecutionContextInterface) : AVD::Validator::ContextualValidatorInterface in_context, start_context : AVD::Validator::ContextualValidatorInterface start_context, validate(value : _, constraints : Array(AVD::Constraint) | AVD::Constraint | Nil = nil, groups : Array(String) | String | AVD::Constraints::GroupSequence | Nil = nil) : AVD::Violation::ConstraintViolationListInterface validate, validate_property(object : AVD::Validatable, property_name : String, groups : Array(String) | String | AVD::Constraints::GroupSequence | Nil = nil) : AVD::Violation::ConstraintViolationListInterface validate_property, validate_property_value(object : AVD::Validatable, property_name : String, value : _, groups : Array(String) | String | AVD::Constraints::GroupSequence | Nil = nil) : AVD::Violation::ConstraintViolationListInterface validate_property_value

Constructor Detail

def self.new(violations : AVD::Violation::ConstraintViolationListInterface = AVD::Violation::ConstraintViolationList.new) #

[View source]

Instance Method Detail

Returns a validator in the provided context.

Violations generated by the returned validator are added to the provided context.


[View source]
def start_context(root = nil) : AVD::Validator::ContextualValidatorInterface #

Creates a new AVD::ExecutionContextInterface and returns a new validator for that context.

Violations generated by the returned validator can be accessed via AVD::Validator::ContextualValidatorInterface#violations.


[View source]
def validate(value : _, constraints : Array(AVD::Constraint) | AVD::Constraint | Nil = nil, groups : Array(String) | String | AVD::Constraints::GroupSequence | Nil = nil) : AVD::Violation::ConstraintViolationListInterface #

:inherit:


[View source]
def validate_property(object : AVD::Validatable, property_name : String, groups : Array(String) | String | AVD::Constraints::GroupSequence | Nil = nil) : AVD::Violation::ConstraintViolationListInterface #

:inherit:


[View source]
def validate_property_value(object : AVD::Validatable, property_name : String, value : _, groups : Array(String) | String | AVD::Constraints::GroupSequence | Nil = nil) : AVD::Violation::ConstraintViolationListInterface #

:inherit:


[View source]
def violations=(violations : AVD::Violation::ConstraintViolationListInterface) #

[View source]