ValidationError: User validation failed at MongooseError.ValidationError ValidationError: User validation failed at MongooseError.ValidationError express express

ValidationError: User validation failed at MongooseError.ValidationError


Reason: reason behind this error is invalid type to store in db. Like mobile is number type but if you are passing a value which can not be convert to number then it will give the same error.

console.log(newUser); before saving the user and check the value you are passing in mobile field is convertible to Number as its data type is number in your schema.

If mobile is "" or undefined or null i.e. not convertible to number then it will not work. Remove this key from object if it's value doesn't exists. Do not pass the undefined,null or "" or string(which can not be convert to number).