Mongoose - array of enum strings Mongoose - array of enum strings mongoose mongoose

Mongoose - array of enum strings


You can try a custom validation?Like this

const userSchema = new Schema({  phone: {    type: String,    validate: {      validator: function(v) {        return /\d{3}-\d{3}-\d{4}/.test(v);      },      message: props => `${props.value} is not a valid phone number!`    },    required: [true, 'User phone number required']  }});