Class: Reform::Form::Dry::Validations::Group
- Inherits:
-
Object
- Object
- Reform::Form::Dry::Validations::Group
- Includes:
- InputHash
- Defined in:
- lib/reform/form/dry.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
- #contract ⇒ 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.
36 37 38 |
# File 'lib/reform/form/dry.rb', line 36 def block @block end |
#schema_inject_params ⇒ Object (readonly)
Returns the value of attribute schema_inject_params.
36 37 38 |
# File 'lib/reform/form/dry.rb', line 36 def schema_inject_params @schema_inject_params end |
#validator ⇒ Object (readonly)
Returns the value of attribute validator.
36 37 38 |
# File 'lib/reform/form/dry.rb', line 36 def validator @validator end |
Instance Method Details
#call(form) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/reform/form/dry.rb', line 42 def call(form) # when passing options[:schema] the class instance is already created so we just need to call # "call" return validator.call(input_hash(form)) unless validator.is_a?(Class) && @validator <= ::Dry::Validation::Contract = { form: form } = schema_inject_params.merge() contract.new().call(input_hash(form)) end |
#contract ⇒ Object
52 53 54 |
# File 'lib/reform/form/dry.rb', line 52 def contract @contract ||= Class.new(validator, &block) end |
#instance_exec(&block) ⇒ Object
38 39 40 |
# File 'lib/reform/form/dry.rb', line 38 def instance_exec(&block) @block = block end |