Class: FormKeeper::CombinationConstraint::Time

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

Instance Method Summary collapse

Instance Method Details

#validate(values, arg) ⇒ Object



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

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]
  (0..23).include?(values[0].to_i) and (0..59).include?(values[1].to_i) and (0..59).include?(values[2].to_i)
end