mirror of
https://github.com/internetee/registry.git
synced 2025-08-11 12:09:34 +02:00
Added validation for one only IP
This commit is contained in:
parent
bf3d971d7c
commit
18cd6f5046
2 changed files with 8 additions and 0 deletions
|
@ -5,6 +5,7 @@ class WhiteIp < ApplicationRecord
|
||||||
validate :valid_ipv4?
|
validate :valid_ipv4?
|
||||||
validate :valid_ipv6?
|
validate :valid_ipv6?
|
||||||
validate :validate_ipv4_and_ipv6
|
validate :validate_ipv4_and_ipv6
|
||||||
|
validate :validate_only_one_ip
|
||||||
before_save :normalize_blank_values
|
before_save :normalize_blank_values
|
||||||
|
|
||||||
def normalize_blank_values
|
def normalize_blank_values
|
||||||
|
@ -17,6 +18,12 @@ class WhiteIp < ApplicationRecord
|
||||||
errors.add(:base, I18n.t(:ipv4_or_ipv6_must_be_present))
|
errors.add(:base, I18n.t(:ipv4_or_ipv6_must_be_present))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def validate_only_one_ip
|
||||||
|
return unless ipv4.present? && ipv6.present?
|
||||||
|
|
||||||
|
errors.add(:base, I18n.t(:ip_must_be_one))
|
||||||
|
end
|
||||||
|
|
||||||
def valid_ipv4?
|
def valid_ipv4?
|
||||||
return if ipv4.blank?
|
return if ipv4.blank?
|
||||||
|
|
||||||
|
|
|
@ -545,6 +545,7 @@ en:
|
||||||
upload_crt: 'Upload CRT'
|
upload_crt: 'Upload CRT'
|
||||||
crt_or_csr_must_be_present: 'CRT or CSR must be present'
|
crt_or_csr_must_be_present: 'CRT or CSR must be present'
|
||||||
ipv4_or_ipv6_must_be_present: 'IPv4 or IPv6 must be present'
|
ipv4_or_ipv6_must_be_present: 'IPv4 or IPv6 must be present'
|
||||||
|
ip_must_be_one: 'Please enter only one IP address'
|
||||||
white_ip: 'White IP'
|
white_ip: 'White IP'
|
||||||
edit_white_ip: 'Edit white IP'
|
edit_white_ip: 'Edit white IP'
|
||||||
confirm_domain_delete: 'Confirm domain delete'
|
confirm_domain_delete: 'Confirm domain delete'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue