I know that obviously every document in the database should validate, but sadly that is not always the case
Either because the database rules have changed (e.g. adding a new field and making it mandatory), or because you have been naughty and (for example) updated a set of eBay categories directly rather than unlinking every document…
Anyway, what is the best way of validating a document server-side on demand? This is so that, if the validation fails, I can a) give a sensible error message and b) stop the process which otherwise will only fail right at the end when you go to doc.save().
Running doc.validate() doesn’t (ordinarily) seem to do anything? (at least on Item documents).
Running doc._validate() does check lots of things, but it doesn’t check links (for example).
I’ve settled on:
doc.validate() # in case of custom stuff
doc._validate() # mandatory errors, invalid errors etc
doc.action = ‘’ # because otherwise the next line has a hissy fit
but I feel like there should be a better way?