Introduce 'optional' validator to epp controllers

This commit is contained in:
Martin Lensment 2015-01-23 13:08:35 +02:00
parent 3a529135ea
commit e6b36c409d
6 changed files with 96 additions and 16 deletions

View file

@ -92,6 +92,19 @@ class EppController < ApplicationController
}
end
def optional(selector, *validations)
full_selector = [@prefix, selector].join(' ')
el = params[:parsed_frame].css(full_selector).first
return unless el && el.text.present?
value = el.text
validations.each do |x|
validator = "#{x.first[0]}_validator".camelize.constantize
err = validator.validate_epp(selector.split(' ').last, value)
epp_errors << err if err
end
end
def xml_attrs_present?(ph, attributes) # TODO: THIS IS DEPRECATED AND WILL BE REMOVED IN FUTURE
attributes.each do |x|
epp_errors << {