Why is my mongoose schema not validating? Why is my mongoose schema not validating? mongoose mongoose

Why is my mongoose schema not validating?


You have used the validators min and max, which are for the Number type.

Try using minlength and maxlength instead, which are for the String type:

var UserSchema = new mongoose.Schema({  username: { type: String, minlength: 3, maxlength: 30, required: true },  password: { type: String, minlength: 6, required: true }});

I hope this helps.