-
Notifications
You must be signed in to change notification settings - Fork 31
Validation
Validation is done in controllers with "joi" package. It validates and does parsing of incoming requests.
There are also some validation rules enforced in Sequelize models, but that is just for additional protection and should be handled before data gets into a repository.
For complex project you can consider moving validation into repositories, so validation is enforced whoever calls repository.
Joi was module initially developed for Hapi (ExpressJs alternative), but it is completely standalone module.
Some links:
http://vawks.com/blog/2014/03/22/the-joi-of-validation/
https://github.com/hapijs/joi/blob/v9.0.0-9/API.md
Client validation rules are a subset of server validation. For example, if you have date picker component on the client, you do not check that it is value is correct date, because it is done inside component itself, but on the server you still have to validate date field, as you cannot trust request data.
Client validation implementation depends on front-end framework.
For React custom validation is used (look at *Form React components).
For Vue.js (alt Vue.js) there is dedicated "vue-validator" package.