Add ip validation to nameserver

This commit is contained in:
Martin Lensment 2014-08-05 17:44:46 +03:00
parent 38f0528d70
commit da950f5df7
6 changed files with 49 additions and 5 deletions

View file

@ -3,5 +3,5 @@ class Nameserver < ActiveRecord::Base
has_and_belongs_to_many :domains
validates :hostname, hostname: true
validates :ip, format: { with: /\A(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\z/, allow_nil: true}
validates :ip, format: { with: /\A(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\z/, allow_nil: true, message: :ip_invalid}
end