Module: Ohm::DateValidations

Included in:
ExtraValidations
Defined in:
lib/ohm/contrib/date_validations.rb

Constant Summary

DATE_REGEX =
/\A([0-9]{4})-([01]?[0-9])-([0123]?[0-9])\z/

Instance Method Summary (collapse)

Instance Method Details

- (Object) assert_date(att, error = [att, :not_date])



7
8
9
10
11
12
# File 'lib/ohm/contrib/date_validations.rb', line 7

def assert_date(att, error = [att, :not_date])
  if assert_format att, DATE_REGEX, error
    m = send(att).to_s.match(DATE_REGEX)
    assert is_date_parseable?(m[1], m[2], m[3]), error
  end
end