mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 18:59:38 +02:00
Domain name validation through EPP
This commit is contained in:
parent
b592b973ff
commit
d2e30c0c5f
3 changed files with 14 additions and 4 deletions
|
@ -1,10 +1,14 @@
|
|||
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
|
||||
unless self.class.validate(value)
|
||||
record.errors[attribute] << (options[:message] || 'invalid format')
|
||||
end
|
||||
end
|
||||
|
||||
class << self
|
||||
def validate(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] == '-')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue