Class: UniqueValidation
- Inherits:
-
Validation
show all
- Defined in:
- lib/yodel/models/core/validations/unique_validation.rb
Instance Attribute Summary
Attributes inherited from Validation
#field, #params
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Validation
#initialize, #to_json
Constructor Details
This class inherits a constructor from Validation
Class Method Details
.validate(params, field, name, value, record, errors) ⇒ Object
2
3
4
|
# File 'lib/yodel/models/core/validations/unique_validation.rb', line 2
def self.validate(params, field, name, value, record, errors)
errors[field.name] << new(params) if record.model.exists?(field.name => value, :_id.ne => record.id)
end
|
Instance Method Details
#describe ⇒ Object
6
7
8
|
# File 'lib/yodel/models/core/validations/unique_validation.rb', line 6
def describe
"must be unique"
end
|