class Sinatra::Chiro::Parameters::TimeValidator

Public Instance Methods

comment() click to toggle source
# File lib/sinatra/chiro/parameters/time.rb, line 15
def comment
  'Must be expressed according to ISO 8601 (ie. hh:mm:ss)'
end
validate(given) click to toggle source
# File lib/sinatra/chiro/parameters/time.rb, line 5
def validate(given)
  Time.parse(given.to_s)

  if given[name] !~ /^\d{2}:\d{2}:\d{2}$/
    "#{name_display} parameter must be a string in the format: hh:mm:ss"
  end
rescue ArgumentError
  "#{name_display} parameter invalid"
end