Class: Valigator::CSV::FieldValidators::Date

Inherits:
Base
  • Object
show all
Defined in:
lib/valigator/csv/field_validators/date.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#==, #initialize

Constructor Details

This class inherits a constructor from Valigator::CSV::FieldValidators::Base

Instance Method Details

#error_messageObject



23
24
25
# File 'lib/valigator/csv/field_validators/date.rb', line 23

def error_message
  'Invalid date field'
end

#error_typeObject



17
18
19
# File 'lib/valigator/csv/field_validators/date.rb', line 17

def error_type
  'invalid_date'
end

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
# File 'lib/valigator/csv/field_validators/date.rb', line 6

def valid?(value)
  return true if allow_blank and blank? value

  parse value
  true
rescue ArgumentError
  false
end