Class: FormKeeper::CombinationConstraint::Date

Inherits:
Base
  • Object
show all
Defined in:
lib/formkeeper.rb

Instance Method Summary collapse

Instance Method Details

#validate(values, arg) ⇒ Object



340
341
342
343
344
345
# File 'lib/formkeeper.rb', line 340

def validate(values, arg)
  return false unless values.size == 3
  return false unless values.all? { |v| v =~ /^[[:digit:]]+$/ }
  # TODO handle range by args[:from] and args[:to]
  ::Date.valid_date?(values[0].to_i, values[1].to_i, values[2].to_i)
end