It's pronounced Diane. I do data architecture, operations, and backend development. In my spare time I maintain Massive.js, a data mapper for Node.js and PostgreSQL.
It's good to validate quickly so you can return easy-to-catch errors to the user with a minimum of waiting, and express-validator or any of several other packages will do that perfectly well. But there's one important thing to remember: only the database can truly enforce validation rules. A validation rule in application code is akin to saying "it'd be nice if that field had something in it". If you want to make sure the field has something in it no matter what, set NOT NULL and add a CHECK constraint (unless you're using MySQL <8, which ignores the latter).
For your situation, Sequelize model validation sounds like the worst of both worlds: slower than early checks, not actually enforced by the database.
Thank you :) I will then move my validation rule checking into a route handler itself and have actual SQL table constraints as a safety net to be absolutely sure my tables don't take undesirable values.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It's good to validate quickly so you can return easy-to-catch errors to the user with a minimum of waiting, and express-validator or any of several other packages will do that perfectly well. But there's one important thing to remember: only the database can truly enforce validation rules. A validation rule in application code is akin to saying "it'd be nice if that field had something in it". If you want to make sure the field has something in it no matter what, set
NOT NULL
and add aCHECK
constraint (unless you're using MySQL <8, which ignores the latter).For your situation, Sequelize model validation sounds like the worst of both worlds: slower than early checks, not actually enforced by the database.
Thank you :) I will then move my validation rule checking into a route handler itself and have actual SQL table constraints as a safety net to be absolutely sure my tables don't take undesirable values.