mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 02:09:39 +02:00
Add XML attribute validator
This commit is contained in:
parent
36e36cf616
commit
01cfddee95
5 changed files with 42 additions and 13 deletions
|
@ -38,6 +38,19 @@ module Epp::Common
|
|||
render '/epp/error'
|
||||
end
|
||||
|
||||
def xml_attrs_present?(ph, attributes)
|
||||
attributes.each do |x|
|
||||
epp_errors << {code: '2003', msg: I18n.t('errors.messages.required_parameter_missing', key: x.last)} unless has_attribute(ph, x)
|
||||
end
|
||||
epp_errors.empty?
|
||||
end
|
||||
|
||||
def has_attribute(ph, path)
|
||||
path.inject(ph) do |location, key|
|
||||
location.respond_to?(:keys) ? location[key] : nil
|
||||
end
|
||||
end
|
||||
|
||||
def validate_request
|
||||
type = OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]
|
||||
return unless type
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue