class SchemaValidations::DateInDbRangeValidator

Public Instance Methods

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

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