Sha256: 2e0615926fd1144a303801285bbc6a7520c74d436d3bb5d3692638d8505375b8

Contents?: true

Size: 692 Bytes

Versions: 102

Compression:

Stored size: 692 Bytes

Contents

# encoding: utf-8
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

102 entries across 97 versions & 7 rubygems

Version Path
mongoid-3.1.7 lib/mongoid/errors/validations.rb
mongoid-4.0.2 lib/mongoid/errors/validations.rb
mongoid-4.0.1 lib/mongoid/errors/validations.rb
mongoid-4.0.0 lib/mongoid/errors/validations.rb
mongoid-4.0.0.rc2 lib/mongoid/errors/validations.rb
mongoid-4.0.0.rc1 lib/mongoid/errors/validations.rb
mongoid-4.0.0.beta2 lib/mongoid/errors/validations.rb
mongoid-4.0.0.beta1 lib/mongoid/errors/validations.rb
mongoid-4.0.0.alpha2 lib/mongoid/errors/validations.rb
mongoid-4.0.0.alpha1 lib/mongoid/errors/validations.rb
mongoid-3.1.6 lib/mongoid/errors/validations.rb
sepastian-mongoid-rails4-4.0.1.alpha lib/mongoid/errors/validations.rb
sepastian-mongoid-rails4-4.0.0.alpha lib/mongoid/errors/validations.rb
mongoid-3.1.5 lib/mongoid/errors/validations.rb
mongoid_heroku_stable-4.0.0 lib/mongoid/errors/validations.rb
mongoid_rails4-4.0.0 lib/mongoid/errors/validations.rb
mongoid-3.1.4 lib/mongoid/errors/validations.rb
mongoid-3.1.3 lib/mongoid/errors/validations.rb
mongoid-3.1.2 lib/mongoid/errors/validations.rb
mongoid-3.0.23 lib/mongoid/errors/validations.rb