mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 11:38:30 +02:00
Validate flags an attributes presence on dnskey
This commit is contained in:
parent
e7644ea69d
commit
338a58a611
3 changed files with 35 additions and 9 deletions
|
@ -3,17 +3,23 @@ class Dnskey < ActiveRecord::Base
|
|||
|
||||
belongs_to :domain
|
||||
|
||||
validates :alg, :protocol, :flags, :public_key, presence: true
|
||||
validate :validate_algorithm
|
||||
validate :validate_protocol
|
||||
validate :validate_flags
|
||||
|
||||
def epp_code_map
|
||||
{
|
||||
'2005' => [
|
||||
[:alg, :invalid, { value: { obj: 'alg', val: alg } }],
|
||||
[:protocol, :invalid, { value: { obj: 'protocol', val: protocol } }],
|
||||
[:flags, :invalid, { value: { obj: 'flags', val: flags } }]
|
||||
],
|
||||
'2306' => [
|
||||
[:ipv4, :blank]
|
||||
[:alg, :blank],
|
||||
[:protocol, :blank],
|
||||
[:flags, :blank],
|
||||
[:public_key, :blank]
|
||||
]
|
||||
}
|
||||
end
|
||||
|
@ -27,4 +33,9 @@ class Dnskey < ActiveRecord::Base
|
|||
return if %w(3).include?(protocol.to_s)
|
||||
errors.add(:protocol, :invalid)
|
||||
end
|
||||
|
||||
def validate_flags
|
||||
return if %w(0 256 257).include?(flags.to_s)
|
||||
errors.add(:flags, :invalid)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue