Enforce Data Validation on Models in Sequelize
Sequelize·1 min read·Jan 1, 2025
In addition to constraints, Sequelize provides a list of built-in model validators implemented by the validator library, that allow you check and validate the data format of columns through the validate property:
{ <column>: { type: <type>, validate: { <validator>: <value>, ... } }}Note: These validators are only executed upon
CREATEandUPDATEoperations.
Validate numbers
To check numbers, you can use:
isNumeric: true: to only allow numbers.isInt: true: to check for valid integers.
Unlock the program 🚀
Pay once, own it forever.
€79
30-day money-back guarantee
- 13 modules
- 113 lessons with full-code examples
- 29 projects with commented solutions
- All future lesson and project updates
- Lifetime access
By submitting this form, you agree to the Terms & Conditions and Privacy Policy.