Class: DateTimeValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/universal_validators_rails.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



13
14
15
16
# File 'lib/universal_validators_rails.rb', line 13

def validate_each(record, attribute, value)
  validator = ::UniversalValidators::DateTimeValidator.new(value)
  record.errors.add(attribute, @options[:message] || 'Invalid date time format') unless validator.valid?
end