Summary

In this chapter, we've seen how to use Mongoose to maintain the data integrity of our application. We have learned about the default validators that are available, and also learned how to use them and how to create custom validators. Within the custom validators, we've covered how to send custom error messages, add multiple validators, and run asynchronous validation. We also took a look at the error object returned when your validators find a problem with the data.

Coming up in the next chapter, we're going to take a look at complex schemas, including nested documents and referencing other schemas.

Get Mongoose for Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.