lib/mongoid/validatable/uniqueness.rb
# Validate the document for uniqueness violations.
#
# @example Validate the document.
#   validate_each(person, :title, "Sir")
#
# @param [ Document ] document The document to validate.
# @param [ Symbol ] attribute The field to validate on.
# @param [ Object ] value The value of the field.
#
# @return [ Errors ] The errors.
Validate the document for uniqueness violations.
Validate the document for uniqueness violations .
def validate_each(document, attribute, value)
        with_query(document) do
          attrib, val = to_validate(document, attribute, value)
          return unless validation_required?(document, attrib)
          if document.embedded?
            validate_embedded(document, attrib, val)
          else
            validate_root(document, attrib, val)
          end
        end
      end
def validate_each ( document , attribute , value ) with_query ( document ) do attrib , val = to_validate ( document , attribute , value ) return unless validation_required? ( document , attrib ) if document . embedded? validate_embedded ( document , attrib , val ) else validate_root ( document , attrib , val ) end end end
Validate the document for uniqueness violations.
Validate the document for uniqueness violations .
None
 Errors 
document
<not_specific>
attribute
<not_specific>
value
<not_specific>
<not_specific>
value The value of the field.
value The value of the field .
example
Validate the document. validate_each(person, :title, "Sir")
Validate the document . validate_each ( person : title " Sir " )