class SchemaValidations::DateTimeInDbRangeValidator

Public Instance Methods

validate_each(record, attr_name, value) click to toggle source
# File lib/generated_schema_validations/template.rb, line 76
def validate_each(record, attr_name, value)
  return if value.nil?
  return unless value.is_a?(DateTime) || value.is_a?(Time)
  return if value.year.between?(-4711, 294275) # see https://www.postgresql.org/docs/9.3/datatype-datetime.html

  record.errors.add(attr_name, :invalid, options)
end