More full paths in error messages

This commit is contained in:
Martin Lensment 2015-01-28 16:22:18 +02:00
parent 01fb195104
commit 7c69783091
3 changed files with 13 additions and 6 deletions

View file

@ -119,24 +119,27 @@ class EppController < ApplicationController
end
def exactly_one_of(*selectors)
full_selectors = create_full_selectors(*selectors)
return if element_count(*selectors) == 1
epp_errors << {
code: '2306',
msg: I18n.t(:exactly_one_parameter_required, params: selectors.join(' or '))
msg: I18n.t(:exactly_one_parameter_required, params: full_selectors.join(' OR '))
}
end
def mutually_exclusive(*selectors)
full_selectors = create_full_selectors(*selectors)
return if element_count(*selectors) <= 1
epp_errors << {
code: '2306',
msg: I18n.t(:mutally_exclusive_params, params: selectors.join(', '))
msg: I18n.t(:mutally_exclusive_params, params: full_selectors.join(', '))
}
end
def optional(selector, *validations)
full_selector = [@prefix, selector].join(' ')
full_selector = [@prefix, selector].compact.join(' ')
el = params[:parsed_frame].css(full_selector).first
return unless el && el.text.present?
value = el.text
@ -151,13 +154,17 @@ class EppController < ApplicationController
def element_count(*selectors)
present_count = 0
selectors.each do |selector|
full_selector = [@prefix, selector].join(' ')
full_selector = [@prefix, selector].compact.join(' ')
el = params[:parsed_frame].css(full_selector).first
present_count += 1 if el && el.text.present?
end
present_count
end
def create_full_selectors(*selectors)
selectors.map { |x| [@prefix, x].compact.join(' ') }
end
def xml_attrs_present?(ph, attributes) # TODO: THIS IS DEPRECATED AND WILL BE REMOVED IN FUTURE
attributes.each do |x|
epp_errors << {