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

required. This will return a validation error if no data is given to a data object with this property. It is super-easy to use. If we want to add it to email in our userSchema we simply need to update the line as follows:

email: { type: String, unique: true, required: true }

From

Cover of Mongoose for Application Development

Note

required validator