Method: Cuprum::ParameterValidation::Validator#call
- Defined in:
- lib/cuprum/parameter_validation/validator.rb
#call(command:, parameters:, rules:) ⇒ Cuprum::Result
Validates the given parameters.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cuprum/parameter_validation/validator.rb', line 26 def call(command:, parameters:, rules:) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength validator.clear rules.each do |rule| value = parameters[rule.name] if rule.type == ValidationRule::BLOCK_VALIDATION_TYPE evaluate_block_validation(rule:, value:) elsif command.respond_to?(rule.method_name, true) evaluate_command_validation(command:, rule:, value:) elsif validator.respond_to?(rule.method_name) evaluate_validation(rule:, value:) else raise UnknownValidationError, (command:, rule:) end end handle_failures_for(command) end |