Class: Reform::Form::Dry::NewApi::Validations::Group
- Inherits:
-
Object
- Object
- Reform::Form::Dry::NewApi::Validations::Group
- Includes:
- InputHash
- Defined in:
- lib/reform/form/dry/new_api.rb
Instance Method Summary collapse
- #call(form) ⇒ Object
-
#initialize(options = {}) ⇒ Group
constructor
A new instance of Group.
- #instance_exec(&block) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Group
Returns a new instance of Group.
23 24 25 26 |
# File 'lib/reform/form/dry/new_api.rb', line 23 def initialize( = {}) @validator = .fetch(:schema, Contract) @schema_inject_params = .fetch(:with, {}) end |
Instance Method Details
#call(form) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/reform/form/dry/new_api.rb', line 32 def call(form) # when passing options[:schema] the class instance is already created so we just need to call # "call" if @validator.is_a?(Class) && @validator <= ::Dry::Validation::Contract = {form: form} = @schema_inject_params.merge() @validator = @validator.build(, &@block) end @validator.call(input_hash(form)) end |
#instance_exec(&block) ⇒ Object
28 29 30 |
# File 'lib/reform/form/dry/new_api.rb', line 28 def instance_exec(&block) @block = block end |