I get this message from Mongoose check:
'Failed to execute validator for empty phone with value ``' '
This should not be, since the phone is not required.
Here is my model diagram:
var user = new Schema(
{
_id : { type: String, required: true },
name : { type: String, required: true},
phone : { type: String, required: false, validate: /^\d{10}$/ },
password : { type: String },
added : { type: Date, default: Date.now },
},
{collection : 'users'}
);
The mongoose check seems to fail when I use required: falseand set the validate property up. If I change it to:
phone : { type: String, required: false},
Everything is going right, why? What am I doing wrong?
source
share