Module: Pathway::Plugins::DryValidation::V0_11::InstanceMethods
- Extended by:
- Forwardable
- Defined in:
- lib/pathway/plugins/dry_validation/v0_11.rb
Instance Method Summary collapse
Instance Method Details
#validate(state, with: nil) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/pathway/plugins/dry_validation/v0_11.rb', line 67 def validate(state, with: nil) if auto_wire && .any? with ||= .zip().to_h end opts = Hash(with).map { |opt, key| [opt, state[key]] }.to_h validate_with(state[:input], opts) .then { |params| state.update(params: params) } end |
#validate_with(params, opts = {}) ⇒ Object
76 77 78 79 80 |
# File 'lib/pathway/plugins/dry_validation/v0_11.rb', line 76 def validate_with(params, opts = {}) val = form(opts).call(params) val.success? ? wrap(val.output) : error(:validation, details: val.) end |