Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 619
Chance Avatar asked Sep 29 '11 16:09

Chance


1 Answers

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.

like image 104
Nican Avatar answered Oct 15 '22 06:10

Nican