When I submit a form that has a blank input field the database is populating with ""
. If the field is required it should error but it doesn’t. Is there a way to prevent this from happening. I’m currently using:
Simple-Schema
Collection2
React
Meteor
MongoDb Example - see name.last for empty field
{
"_id": "R2xGMGoKDJc3CvwJ2",
"userId": "fYHKGTRhZvPKCETHQ",
"createdAt": "2017-05-08T03:08:02.597Z",
"name": {
"first": "John",
"last": ""
}
}
Path: Schema
ProfileCandidate.schema = new SimpleSchema({
userId: {
type: String,
},
createdAt: {
type: Date,
},
name: Object,
'name.first': String,
'name.last': String,
}, {
clean: {
filter: true,
autoConvert: true,
removeEmptyStrings: true,
trimStrings: true,
getAutoValues: false,
removeNullsFromArrays: true,
},}).newContext();
ProfileCandidate.schema.validate({
userId: String,
createdAt: Date,
name: Object,
'name.first': String,
'name.last': String,
});