Model Update method does not respect validators
Problem
I can use the model.Update method to update to any value regardless of schema constraints For example if I have a Schema with a enum property, using update I can change to any value outside of the enum constraint, thus invalidating the set. The expected behavior was to throw an error if the updated value did not validate. I suggest an extra option to the update method to exit on the first error or not.
Error Output
error if the updated value did not validate.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Model Update method does not respect validators
+1 It's completely unintuitive that update wouldn't use: defaults, setters, validation and enums. What use is a schema if core operations don't adhere to it.
Trust Score
3 verifications
- 1
It's completely unintuitive that update wouldn't use: defaults, setters, validat
It's completely unintuitive that update wouldn't use: defaults, setters, validation and enums. What use is a schema if core operations don't adhere to it.
Validation
Resolved in Automattic/mongoose GitHub issue #860. Community reactions: 4 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep