Getting ready
Let's add validation to our blog post model so that we won't save values that don't match our expectations. We will add validations for required fields and character lengths for our title. We will also add a custom validation that will use a regular expression to validate a property.
We will also extend the functionality of our blog post by adding support for markdown. Markdown is a common format for rich text content, such as blog posts. We will use a Mongoose virtual property to convert our markdown content to normal HTML for the purposes of displaying posts in our application.
To work with markdown and make sure we perform our HTML conversion in a safe manner, we will need to install the popular markdown library, showdown ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access