Validate protocol in dnskey

This commit is contained in:
Martin Lensment 2014-10-02 11:15:46 +03:00
parent f776078214
commit e7644ea69d
3 changed files with 22 additions and 8 deletions

View file

@ -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