This commit is contained in:
Martin Lensment 2014-08-05 17:50:20 +03:00
parent da950f5df7
commit a9e1414ddc
4 changed files with 3 additions and 31 deletions

View file

@ -1,13 +0,0 @@
class HostnameValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
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

View file

@ -1,15 +0,0 @@
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