mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 01:33:36 +02:00
parent
0f352cab24
commit
d520b5b157
50 changed files with 2462 additions and 323 deletions
13
lib/validators/iso8601_validator.rb
Normal file
13
lib/validators/iso8601_validator.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
class Iso8601Validator < ActiveModel::EachValidator
|
||||
def validate_each(record, attribute, value)
|
||||
if options[:date_only]
|
||||
record.errors.add(attribute, :invalid_iso8601_date) unless value =~ date_format
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def date_format
|
||||
/\d{4}-\d{2}-\d{2}/
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue