class Athena::Validator::Spec::MockValidator
inherits Reference
#
A spec implementation of AVD::Validator::ValidatorInterface
.
Allows settings the violations that should be returned, defaulting to no violations. Also allows providing a block that is called for each validated value. E.g. to allow dynamically configuring the returned violations after it is instantiated.
Included modules
Athena::Validator::Validator::ValidatorInterface
Constructors#
.new(violations : AVD::Violation::ConstraintViolationListInterface = AVD::Violation::ConstraintViolationList.new) : self
#
Methods#
#in_context(context : AVD::ExecutionContextInterface) : AVD::Validator::ContextualValidatorInterface
#
Returns a validator in the provided context.
Violations generated by the returned validator are added to the provided context.
#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
.
#validate(value : _, constraints : Array(AVD::Constraint) | AVD::Constraint | Nil = nil, groups : Array(String) | String | AVD::Constraints::GroupSequence | Nil = nil) : AVD::Violation::ConstraintViolationListInterface
#
:inherit:
#validate_property(object : AVD::Validatable, property_name : String, groups : Array(String) | String | AVD::Constraints::GroupSequence | Nil = nil) : AVD::Violation::ConstraintViolationListInterface
#
:inherit:
#validate_property_value(object : AVD::Validatable, property_name : String, value : _, groups : Array(String) | String | AVD::Constraints::GroupSequence | Nil = nil) : AVD::Violation::ConstraintViolationListInterface
#
:inherit: