class Valigator::CSV::FieldValidators::Date

Public Instance Methods

error_message() click to toggle source
# File lib/valigator/csv/field_validators/date.rb, line 23
def error_message
  'Invalid date field'
end
error_type() click to toggle source
# File lib/valigator/csv/field_validators/date.rb, line 17
def error_type
  'invalid_date'
end
valid?(value) click to toggle source
# 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

Private Instance Methods

format() click to toggle source
# File lib/valigator/csv/field_validators/date.rb, line 31
def format
  @options[:format]
end
parse(value) click to toggle source
# File lib/valigator/csv/field_validators/date.rb, line 37
def parse(value)
  format ? ::Date.strptime(value.to_s, format) : ::Date.parse(value.to_s)
end