class Sinatra::Chiro::Parameters::DateTimeValidator
Public Instance Methods
comment()
click to toggle source
# File lib/sinatra/chiro/parameters/datetime.rb, line 14 def comment 'Must be expressed according to ISO 8601 (ie. YYYY-MM-DDThh:mm:ss)' end
validate(given)
click to toggle source
# File lib/sinatra/chiro/parameters/datetime.rb, line 5 def validate(given) DateTime.parse(given.to_s) if given[name] !~ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/ "#{name_display} parameter must be a string in the format: yyyy-mm-ddThh:mm:ss" end rescue ArgumentError "#{name_display} parameter invalid" end