I am starting a new Meteor project and am using Collection2 for validation. I have the below schema defined. When I insert a document with title: 4, I expect it to fail since I have specified it as a String. It is not failing. I suspect there is some fundamental aspect of Meteor I'm not getting. FYI, if I leave out the title, I get the expected errors.
My schema:
Timestamps = new Mongo.Collection('timestamps');
var Schemas = {};
Schemas.Timestamp = new SimpleSchema({
title: {
type: String,
label: "Title",
max: 500,
optional: false
},
notes: {
type: String,
label: "Notes",
max: 1000,
optional: true
}
});
Timestamps.attachSchema(Schemas.Timestamp);
The following code should fail with an error saying title needs to be a String. However, it is not failing, and the value is being stored as a string "4".
Creating a timestamp:
Timestamps.insert({title: 4, comments: "a comment"});
This is how I am publishing and allowing timestamp inserts.
Meteor.publish("timestamps", function() {
return Timestamps.find();
});
Timestamps.allow({
insert: function(timestamp) {
return true;
}
});