A Meteor package that extends Mongo.Collection to provide support for specifying a schema and then validating against that schema when inserting and updating.
I have defined a schema for a meteor mongo collection using smpl-schema and I'm getting some confusing behavior. I'm trying to define an Array of Objects which validates fine, but on insert fails.
import SimpleSchema from 'simpl-schema';
const Schemas = {};
const resourceCollection = new Mongo.Collection('resourcecollection');
Schemas.resourceCollectionSchema = new SimpleSchema({
resourceTypes: {
type: Array,
label: `The resources for a this collection`
},
"resourceTypes.$": {
type: Object,
blackbox: true
},
"resourceTypes.$.blah": {
type: String
}
}).validate({
resourceTypes: [
{
"blah": "blah"
}
]
});
The validate method validates fine. But when I insert
I have defined a schema for a meteor mongo collection using
smpl-schema
and I'm getting some confusing behavior. I'm trying to define an Array of Objects which validates fine, but on insert fails.The validate method validates fine. But when I insert
I get
Error: After filtering out keys not in the schema, your object is now empty
How could validate pass but insert fail?