Algorithm validation for dnskey

This commit is contained in:
Martin Lensment 2014-10-02 10:58:46 +03:00
parent 17e1668794
commit f776078214
3 changed files with 67 additions and 1 deletions

View file

@ -1,3 +1,25 @@
class Dnskey < ActiveRecord::Base
include EppErrors
belongs_to :domain
validate :validate_algorithm
def epp_code_map
{
'2005' => [
[:alg, :invalid, { value: { obj: 'alg', val: alg } }]
],
'2306' => [
[:ipv4, :blank]
]
}
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
end