Class: FormKeeper::CombinationConstraint::DateTime

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

Instance Method Summary collapse

Instance Method Details

#validate(values, arg) ⇒ Object



358
359
360
361
362
363
# File 'lib/formkeeper.rb', line 358

def validate(values, arg)
  return false unless values.size == 6
  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) and (0..23).include?(values[3].to_i) and (0..59).include?(values[4].to_i) and (0..59).include?(values[5].to_i)
end