O'Reilly logo
  • Patrick S thinks this is interesting:

  • match: This validator is for matching against a regular expression
  • enum: This validator is for checking against a provided list of possible values

Here the match validator will check that the string matches the regular expression:

var weekdaySchema = new Schema({
  day : {type: String, match: /^(mon|tues|wednes|thurs|fri)day$/i}

Here the enum validator


Cover of Mongoose for Application Development


match and enum validators