Class: Reform::Form::Dry::OldApi::Validations::Group
- Inherits:
-
Object
- Object
- Reform::Form::Dry::OldApi::Validations::Group
- Includes:
- InputHash
- Defined in:
- lib/reform/form/dry/old_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.
20 21 22 23 24 25 26 |
# File 'lib/reform/form/dry/old_api.rb', line 20 def initialize( = {}) ||= {} schema_class = [:schema] || Reform::Form::Dry::OldApi::Schema @validator = Dry::Validation.Schema(schema_class, build: false) @schema_inject_params = [:with] || {} end |
Instance Method Details
#call(form) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/reform/form/dry/old_api.rb', line 39 def call(form) = {} [:form] = form if @schema_inject_params[:form] = @schema_inject_params.merge() # TODO: only pass submitted values to Schema#call? dry_result = call_schema(, input_hash(form)) # dry_messages = dry_result.messages return dry_result _reform_errors = Reform::Contract::Errors.new(dry_result) # TODO: dry should be merged here. end |
#instance_exec(&block) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/reform/form/dry/old_api.rb', line 28 def instance_exec(&block) @validator = Dry::Validation.Schema(@validator, build: false, &block) # inject the keys into the configure block automatically keys = @schema_inject_params.keys @validator.class_eval do configure do keys.each { |k| option k } end end end |