MODULO Full Stack Web Development: The Ultimate Master SagaTHEORY
Validate a document before saving
Define a Mongoose schema for a reading-list entry with a required book title and a numeric page count of at least one. Use validateSync on a valid entry, an empty title and a negative page count.
Check your work
A title with a positive page count should pass these checks. Inspect the error path for each invalid entry. Validating locally lets you check the rule without writing any records.
