mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 20:18:22 +02:00
Attach nameservers with attributes
This commit is contained in:
parent
356835bebf
commit
d46640713b
6 changed files with 79 additions and 3 deletions
15
app/validators/nameserver_ip_validator.rb
Normal file
15
app/validators/nameserver_ip_validator.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
class NameserverIpValidator < ActiveModel::EachValidator
|
||||
def validate_each(record, attribute, value)
|
||||
if record.domain_
|
||||
|
||||
if !self.class.validate_format(value)
|
||||
record.errors.add(attribute, (options[:message] || :invalid))
|
||||
end
|
||||
end
|
||||
|
||||
class << self
|
||||
def validate_format(value)
|
||||
!!(value =~ /\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue