Class: Reform::Form::Validate::Skip::AllBlank

Inherits:
Object
  • Object
show all
Includes:
Uber::Callable
Defined in:
lib/reform/form/validate.rb

Instance Method Summary collapse

Instance Method Details

#call(input:, binding:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/reform/form/validate.rb', line 7

def call(input:, binding:, **)
  # TODO: Schema should provide property names as plain list.
  # ensure param keys are strings.
  params = input.each_with_object({}) { |(k, v), hash|
    hash[k.to_s] = v
  }

  # return false if any property inputs are populated.
  binding[:nested].definitions.each do |definition|
    value = params[definition.name.to_s]
    return false if (!value.nil? && value != '')
  end

  true # skip this property
end