Class: InputSanitizer::V1::DateConverter
- Inherits:
-
Object
- Object
- InputSanitizer::V1::DateConverter
- Defined in:
- lib/input_sanitizer/v1/default_converters.rb
Constant Summary collapse
- ISO_RE =
/\A\d{4}-?\d{2}-?\d{2}/
Instance Method Summary collapse
Instance Method Details
#call(value) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/input_sanitizer/v1/default_converters.rb', line 24 def call(value) raise InputSanitizer::ConversionError.new("invalid time") unless value =~ ISO_RE Date.parse(value) rescue ArgumentError raise InputSanitizer::ConversionError.new("invalid iso8601 date") end |