class WCC::Contentful::App::ValidationError

Raised by {WCC::Contentful.validate_models!} if a content type in the space does not match the validation defined on the associated model.

Constants

Message

Attributes

errors[R]

Public Class Methods

join_msg_keys(hash) click to toggle source

Turns the error messages hash into an array of message structs like: menu.fields.name.type: must be equal to String

# File lib/wcc/contentful/app/exceptions.rb, line 23
def self.join_msg_keys(hash)
  ret =
    hash.map do |k, v|
      if v.is_a?(Hash)
        msgs = join_msg_keys(v)
        msgs.map { |msg| Message.new(k.to_s + '.' + msg.path, msg.error) }
      else
        v.map { |msg| Message.new(k.to_s, msg) }
      end
    end
  ret.flatten(1)
end
new(errors) click to toggle source
Calls superclass method
# File lib/wcc/contentful/app/exceptions.rb, line 16
def initialize(errors)
  @errors = ValidationError.join_msg_keys(errors)
  super("Content Type Schema from Contentful failed validation!\n  #{@errors.join("\n  ")}")
end