Do I need to check, misinform or delete data when using the build method in the secelize.js file

I have a node / express / sequelize application. I use the build in sequelize method to instantiate my foo model.

Foo controller

 exports.create = function(req, res) {
     var foo = db.Foo.build(req.body);
     foo.save().then(function(){
         // do stuff
     });
 }

Model Foo

module.exports = function(sequelize, DataTypes) {

var Foo = sequelize.define('Foo', 
{
  bar: DataTypes.STRING,
  baz: DataTypes.STRING
}

Does the build method verify that the data I save is clean, or do I need to take some extra precautions here?

+4
source share
1 answer

I prefer to do secondary validation on routes because:

1) - , . , . , .

2) sequelize (, ), .

, " " (, 200 ). . (, max large 100, 150 , ).

, , : sequelize validation - . . NodeJS/express - API , XSS.

+2

Source: https://habr.com/ru/post/1609184/


All Articles