I am using Collection 2 and simpl schema npm package. At the moment I am thinking about using the mdg:validated-method package. I explored the code, and I was not able to understand the below code.
That’s not a validated method, but to answer your question, anything in a Tracker will re-run if any reactive data inside changes. In that example, the reactive data is the cursor. So, basically, if the todo list changes, it will be revalidated.
If I pass my whole document as one parameter like so
insertDocument.call(doc)
how can I validate then the doc holding all the fields? I just want to avoid write to much code and do not want to copy my existing collection definition. I just want to validate against my existing collection with MyCollection.validate(doc). Is that possible, or do I have to mention now every parameter in my method again.
At the moment I validate at the client simply with this MyCollection.validate(doc);
// Validation function for the arguments. Only keyword arguments are accepted,
// so the arguments are an object rather than an array. The SimpleSchema validator
// throws a ValidationError from the mdg:validation-error package if the args don't
// match the schema
validate: new SimpleSchema({
listId: { type: String },
name: { type: String },
desc: { type: String },
}).validator(),