class Interaktor::Error::AttributeSchemaValidationError
Attributes
validation_errors[R]
@return [Hash{Symbol=>Array<String>}]
Public Class Methods
new(interaktor, validation_errors)
click to toggle source
@param interaktor [Class] @param validation_errors
[Hash{Symbol=>Array<String>}]
Calls superclass method
Interaktor::Error::Base::new
# File lib/interaktor/error/attribute_schema_validation_error.rb, line 7 def initialize(interaktor, validation_errors) super(interaktor) @validation_errors = validation_errors end
Public Instance Methods
message()
click to toggle source
@return [String] @abstract
# File lib/interaktor/error/attribute_schema_validation_error.rb, line 15 def message "Interaktor attribute schema failed validation:\n #{error_list}" end
Private Instance Methods
error_entry(key, value, depth = 0)
click to toggle source
# File lib/interaktor/error/attribute_schema_validation_error.rb, line 32 def error_entry(key, value, depth = 0) result = " " * depth * 2 case value when Hash result << "#{key}:\n" value.each do |sub_key, sub_value| result << " " result << error_entry(sub_key, sub_value, depth + 1) end when Array result << "#{key}:\n" value.each do |error_message| result << " " result << error_entry(nil, error_message, depth + 1) end else result << "- #{value}\n" end result end
error_list()
click to toggle source
@return [String]
# File lib/interaktor/error/attribute_schema_validation_error.rb, line 22 def error_list result = "" validation_errors.each do |attribute, errors| result << error_entry(attribute, errors) end result end