Module: MongoODM::Document::Validations::ClassMethods

Defined in:
lib/mongo_odm/document/validations.rb

Instance Method Summary collapse

Instance Method Details

#validates_uniqueness_of(*args) ⇒ Object

Validates whether or not a field is unique against the documents in the database.

Examples:


class Person
  include MongoODM::Document
  field :title

  validates_uniqueness_of :title
end

Parameters:

  • *args (Array)

    The arguments to pass to the validator.



59
60
61
# File 'lib/mongo_odm/document/validations.rb', line 59

def validates_uniqueness_of(*args)
  validates_with(UniquenessValidator, _merge_attributes(args))
end