Class: Jschematic::Attributes::Format::Date

Inherits:
Object
  • Object
show all
Includes:
Element
Defined in:
lib/jschematic/attributes/format.rb

Instance Attribute Summary

Attributes included from Element

#id, #parent

Instance Method Summary collapse

Methods included from Element

#required?, #schema_for, #title, #to_s

Instance Method Details

#accepts?(date) ⇒ Boolean

Returns:

  • (Boolean)


71
72
73
74
75
76
# File 'lib/jschematic/attributes/format.rb', line 71

def accepts?(date)
  raise ArgumentError unless date =~ /^\d{4}-\d{2}-\d{2}$/
  ::Date.strptime(date)
rescue ArgumentError
  false
end