Class: LedgerSync::Type::Date
- Inherits:
-
ActiveModel::Type::Date
- Object
- ActiveModel::Type::Date
- LedgerSync::Type::Date
show all
- Includes:
- ValueMixin
- Defined in:
- lib/ledger_sync/type/date.rb
Overview
Instance Method Summary
collapse
Methods included from ValueMixin
#assert_valid, #cast, included
Instance Method Details
#type ⇒ Object
10
11
12
|
# File 'lib/ledger_sync/type/date.rb', line 10
def type
:date
end
|
#valid?(args = {}) ⇒ Boolean
14
15
16
17
18
19
20
21
22
|
# File 'lib/ledger_sync/type/date.rb', line 14
def valid?(args = {})
return false unless valid_class?(args)
value = args.fetch(:value)
return true unless value.is_a?(::String)
return false unless value =~ /\A[0-9]{4}-[0-9]{2}-[0-9]{2}\z/
true
end
|
#valid_classes ⇒ Object
24
25
26
|
# File 'lib/ledger_sync/type/date.rb', line 24
def valid_classes
[::Date, ::String]
end
|