Welcome to mirror list, hosted at ThFree Co, Russian Federation.

iso8601_date_validator.rb « validators « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2b4682f057265fd4eebe32adeace9f8489c94e37 (plain)
1
2
3
4
5
6
7
8
9
# frozen_string_literal: true

class Iso8601DateValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    Date.iso8601(record.read_attribute_before_type_cast(attribute).to_s)
  rescue ArgumentError, TypeError
    record.errors.add(attribute, _('must be in ISO 8601 format'))
  end
end