-
Type: Task
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
validates_uniqueness_of for a String field has case_insensitive option.
By analogy, validates_uniqueness_of for an Array field should have order_insensitive option.
This can be done using this:
validate_uniqueness_of :my_array_field #=> # values = my_array_field.uniq # Klass.where(my_array_field: { "$size" => values.size, "$all" => values }).ne(_id: self._id).exists?
This is not a critical issue but I came across this while coding and thought it would make sense to add.
- is related to
-
MONGOID-5389 Uniqueness validation of Sets and HABTM associations should be order-insensitive
- Backlog