Open ijsf opened 8 years ago
Just noticed that a validate
function does exist, though I guess a similar function that wouldn't check for missing keys would be more useful.
Hmm ya it looks like the internal validation isn't called when using loadOneAndUpdate
. Nice catch. I'll include this fix in the upcoming update.
Thanks!
I am currently having an issue with the model/scheme validation in case of a
loadOneAndUpdate
call.Specifically, consider the normal
create
function, as in camo's examples, which obviously validates the input. I've added a quite strict model as well:However, let's say I want to update the
breed
of a specified Dog entry. In this case, I would use theloadOneAndUpdate
function since I want the other values to remain the same, and thecreate
function obviously wouldn't work because of the missingname
:Note that the breed does not adhere to the model here. Yet, the document is actually updated with this invalid value.
To solve this issue, I guess
loadOneAndUpdate
would have to do some kind of validation. Perhaps additionally, an explicit validation functionvalidate
could be used and exposed which validates any given data against the model.