An opinionated implementation of the Command pattern for Ruby applications. Cuprum wraps your business logic in a consistent, object-oriented interface and features status and error management, composability and control flow management.
Class methods for parameter validation.
#validate(name, **options) => #validate(name, using:, **options) => #validate(name, **options, &block) => #validate(name, type, **options) => Object#validate(name, **options) =>
Defines a validation for the specified parameter.
This validation will call the #validate_$name method on the command with the value of the named parameter. If the method returns a failure message, that message is added to the failed validations.
#validate(name, using:, **options) =>
Defines a validation for the specified parameter.
This validation will call the named method on the command with the value of the named parameter. If the method returns a failure message, that message is added to the failed validations.
#validate(name, **options, &block) =>
Defines a validation for the specified parameter.
This validation will call the given block with the value of the named parameter. If the block returns nil or false, a failure message is added to the failed validations
#validate(name, type, **options) => Object
Defines a validation for the specified parameter.
This validation will call the #validate_$type method on the command with the value of the named parameter. If the method returns a failure message, that message is added to the failed validations.
If the command does not define the method, it will call the SleepingKingStudios::Tools::Assertions instance method with the same name. If the validation fails, the failure message is added to the failed validations.
Back to Documentation | Reference | Cuprum | Cuprum::ParameterValidation