Module: LooseChange::Validations

Included in:
Base
Defined in:
lib/loose_change/validations.rb

Defined Under Namespace

Classes: UniquenessValidator

Instance Method Summary collapse

Instance Method Details

#validates_uniqueness_of(property, opts = {}) ⇒ Object

Ensure that only one document of this class can be created with each value. The :allow_nil option can be set to true to allow any number of documents with a blank value for this property.



7
8
9
10
# File 'lib/loose_change/validations.rb', line 7

def validates_uniqueness_of(property, opts = {})
  view_by property
  validates_with UniquenessValidator, :property => property, :allow_nil => opts[:allow_nil]
end