How do you handle form validation, especially with nested models, in Node.js + Express + Mongoose + Jade


How are you handling form validation with Express and Mongoose? Are you using custom methods, some plugin, or the default errors array?

While I could possibly see using the default errors array for some very simple validation, that approach seems to blow up in the scenario of having nested models.

Problem courtesy of: Chance


I personally use node-validator for checking if all the input fields from the user is correct before even presenting it to Mongoose.

Node-validator is also nice for creating a list of all errors that then can be presented to the user.

Solution courtesy of: Nican

View additional discussion.