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

后端 未结 3 683
隐瞒了意图╮
隐瞒了意图╮ 2021-02-02 16:04

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

3条回答
  •  花落未央
    2021-02-02 17:01

    I personaly use express-form middleware to do validation; it also has filter capabilities. It's based on node-validator but has additional bonuses for express. It adds a property to the request object indicating if it's valid and returns an array of errors.

    I would use this if you're using express.

提交回复
热议问题