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 Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#schema_inject_params ⇒ Object
readonly
Returns the value of attribute schema_inject_params.
-
#validator ⇒ Object
readonly
Returns the value of attribute validator.
Instance Method Summary collapse
- #call(form) ⇒ Object
-
#initialize(**options) ⇒ Group
constructor
A new instance of Group.
- #instance_exec(&block) ⇒ Object
Constructor Details
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
28 29 30 |
# File 'lib/reform/form/dry/new_api.rb', line 28 def block @block end |
#schema_inject_params ⇒ Object (readonly)
Returns the value of attribute schema_inject_params.
28 29 30 |
# File 'lib/reform/form/dry/new_api.rb', line 28 def schema_inject_params @schema_inject_params end |
#validator ⇒ Object (readonly)
Returns the value of attribute validator.
28 29 30 |
# File 'lib/reform/form/dry/new_api.rb', line 28 def validator @validator end |
Instance Method Details
#call(form) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/reform/form/dry/new_api.rb', line 34 def call(form) return validator.call(input_hash(form)) unless validator.is_a?(Class) && @validator <= ::Dry::Validation::Contract = { form: form } = schema_inject_params.merge() validator.build(, &block).call(input_hash(form)) end |
#instance_exec(&block) ⇒ Object
30 31 32 |
# File 'lib/reform/form/dry/new_api.rb', line 30 def instance_exec(&block) @block = block end |