mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 12:47:29 +02:00
11 lines
271 B
Ruby
11 lines
271 B
Ruby
class Iso8601Validator < ActiveModel::EachValidator
|
|
def validate_each(record, attribute, value)
|
|
record.errors.add(attribute, :invalid_iso8601_date) if options[:date_only] && value !~ date_format
|
|
end
|
|
|
|
private
|
|
|
|
def date_format
|
|
/\d{4}-\d{2}-\d{2}/
|
|
end
|
|
end
|