Validation on update/modify
How do I enforce a custom vailidation on update/modify operation? Both clean method and attribute.validate don't work, they work only on save() Thank you
Looks like your right.
Both modify and update don't call validate and thus clean.
Looks like only save calls validate and clean.
Will using save instead of update / modify work?
Looks like this relates to issue #1287.
By this comment, @lafrech seems to think it's not unreasonable to modify update to support validation and clean.
I think it's a good idea to add validation on these operations.. It doesn't make any sense that you could bypass the db enforcment on update.
Agreed.
@bagerard @erdenezul Would one of you accept a PR for this?
?
@gbroques sure, totally :)
@013ymc Do you want to put up a PR for this?
I can help review it, and @erdenezul can merge.
Any follow up on this? It would be a really interesting addition to the package I had to stop using update because of this. The update method is preferable to update instead of having to edit the Document doc object attributes and calling doc.save() it after. When I need to update multiple objects I'm currently iterating over all docs in a collection when update supported update_many with the multi flag.
Any updates on this? It would be great to have optional validation on update
Would also really like some updates on this!
Looks like your right. ... Looks like only save calls
validateandclean.Will using
saveinstead ofupdate/modifywork?
I am calling save after update. It isn't validating. Am I understanding it wrongly?
It would be great to have validation on update or modify...