Sha256: d5657e1e7ac71b68fe7c38d7ee3356d596c9102fadfa9cbbbb5c8fcd94a34434

Contents?: true

Size: 705 Bytes

Versions: 25

Compression:

Stored size: 705 Bytes

Contents

# frozen_string_literal: true

module Mongoid
  module Errors

    # Raised when a persistence method ending in ! fails validation. The message
    # will contain the full error messages from the +Document+ in question.
    #
    # @example Create the error.
    #   Validations.new(person.errors)
    class Validations < MongoidError
      attr_reader :document
      alias :record :document

      def initialize(document)
        @document = document

        super(
          compose_message(
            "validations",
            {
              document: document.class,
              errors: document.errors.full_messages.join(", ")
            }
          )
        )
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
mongoid-8.1.8 lib/mongoid/errors/validations.rb
mongoid-8.1.7 lib/mongoid/errors/validations.rb
mongoid-8.1.6 lib/mongoid/errors/validations.rb
mongoid-8.0.8 lib/mongoid/errors/validations.rb
mongoid-8.1.5 lib/mongoid/errors/validations.rb
mongoid-8.1.4 lib/mongoid/errors/validations.rb
mongoid-8.0.7 lib/mongoid/errors/validations.rb
mongoid-8.1.3 lib/mongoid/errors/validations.rb
mongoid-8.1.2 lib/mongoid/errors/validations.rb
mongoid-8.0.6 lib/mongoid/errors/validations.rb
mongoid-7.5.4 lib/mongoid/errors/validations.rb
mongoid-8.1.1 lib/mongoid/errors/validations.rb
mongoid-8.0.5 lib/mongoid/errors/validations.rb
mongoid-8.1.0 lib/mongoid/errors/validations.rb
mongoid-7.5.3 lib/mongoid/errors/validations.rb
mongoid-8.0.4 lib/mongoid/errors/validations.rb
mongoid-8.0.3 lib/mongoid/errors/validations.rb
mongoid-7.5.2 lib/mongoid/errors/validations.rb
mongoid-8.0.2 lib/mongoid/errors/validations.rb
mongoid-7.5.1 lib/mongoid/errors/validations.rb