hagopj13 / node-express-boilerplate

A boilerplate for building production-ready RESTful APIs using Node.js, Express, and Mongoose
MIT License
6.99k stars 2.05k forks source link

Why doesn't the UserSchema's password validation uses the password definition in custom.validation.js? #194

Open MichaelSel opened 2 years ago

MichaelSel commented 2 years ago

The password validation in the user.model.js file is identical to the one defined in custom.validation.js. Is this code duplication by design or an oversight?

alibabayev0 commented 2 years ago

If you wrote about validation function to seperate then none of them. Models should be responsible of their own validation, which joi validation on top level of arch, should be responsible of incoming data, which can be different from model. The common code is regex expression which could be seperated out (to utils folder maybe).