Improve Ident validation, extract Ident from Contact

#569
This commit is contained in:
Artur Beljajev 2017-08-18 13:24:56 +03:00
parent c5e1516d89
commit feb8d83a26
17 changed files with 809 additions and 195 deletions

View file

@ -11,6 +11,12 @@ module EppErrors
epp_errors << collect_child_errors(attr)
end
if self.class.reflect_on_aggregation(attr)
aggregation = send(attr)
epp_errors << collect_aggregation_errors(aggregation)
next
end
epp_errors << collect_parent_errors(attr, errors)
end
@ -46,6 +52,31 @@ module EppErrors
epp_errors
end
def collect_aggregation_errors(aggregation)
epp_errors = []
aggregation.errors.details.each do |attr, error_details|
error_details.each do |error_detail|
aggregation.class.epp_code_map.each do |epp_code, attr_to_error|
epp_code_found = attr_to_error.any? { |i| i == [attr, error_detail[:error]] }
if epp_code_found
message = aggregation.errors.generate_message(attr, error_detail[:error], error_detail)
message = aggregation.errors.full_message(attr, message)
if attr != :base
message = "#{aggregation.model_name.human} #{message.camelize(:lower)}"
end
epp_errors << { code: epp_code, msg: message }
end
end
end
end
epp_errors
end
def find_epp_code_and_value(msg)
epp_code_map.each do |code, values|
values.each do |x|