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



349
350
351
352
353
354
# File 'lib/formkeeper.rb', line 349

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