mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 08:52:04 +02:00
10 lines
326 B
Ruby
10 lines
326 B
Ruby
class DomainNameValidator < ActiveModel::EachValidator
|
|
def validate_each(record, attribute, value)
|
|
ok = value =~ /\A[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]\.ee\z/
|
|
ok &&= !(value[2] == '-' && value[3] == '-')
|
|
|
|
unless ok
|
|
record.errors[attribute] << (options[:message] || 'invalid format')
|
|
end
|
|
end
|
|
end
|