mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 03:58:27 +02:00
Validate protocol in dnskey
This commit is contained in:
parent
f776078214
commit
e7644ea69d
3 changed files with 22 additions and 8 deletions
|
@ -4,11 +4,13 @@ class Dnskey < ActiveRecord::Base
|
|||
belongs_to :domain
|
||||
|
||||
validate :validate_algorithm
|
||||
validate :validate_protocol
|
||||
|
||||
def epp_code_map
|
||||
{
|
||||
'2005' => [
|
||||
[:alg, :invalid, { value: { obj: 'alg', val: alg } }]
|
||||
[:alg, :invalid, { value: { obj: 'alg', val: alg } }],
|
||||
[:protocol, :invalid, { value: { obj: 'protocol', val: protocol } }],
|
||||
],
|
||||
'2306' => [
|
||||
[:ipv4, :blank]
|
||||
|
@ -16,10 +18,13 @@ class Dnskey < ActiveRecord::Base
|
|||
}
|
||||
end
|
||||
|
||||
|
||||
def validate_algorithm
|
||||
return if %w(3 5 6 7 8 252 253 254 255).include?(alg.to_s)
|
||||
errors.add(:alg, :invalid)
|
||||
# , format: {with: /3|5|6/, message: :alg_invalid}
|
||||
end
|
||||
|
||||
def validate_protocol
|
||||
return if %w(3).include?(protocol.to_s)
|
||||
errors.add(:protocol, :invalid)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue