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(form, options) ⇒ 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(form, options)
  # TODO: Schema should provide property names as plain list.
  # ensure param keys are strings.
  params = options[:input].each_with_object({}) { |(k, v), hash|
    hash[k.to_s] = v
  }

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

  true # skip this property
end