mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 01:47:18 +02:00
Introduce 'optional' validator to epp controllers
This commit is contained in:
parent
3a529135ea
commit
e6b36c409d
6 changed files with 96 additions and 16 deletions
|
@ -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 << {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue