https://sequelize.org/master/manual/getting-started.html
npm install --save sequelize # Install sequelize
npm install --save pg pg-hstore # Install Postgres
Aka "Model validators" Ways of protecting database data types... Not to be confused with Constraints Model validators allow you to specify format/content/inheritance validations for each attribute of the model.
- custom/arbitrary
- built-in
notEmpty
, isEmail
, isAlphanumeric
, notContains
class User extends Model {}
User.init({
name: {
type: DataTypes.STRING,
allowNull: false,
validate: {
notNull: {
msg: 'Please enter your name'
},
notEmpty: {
msg: 'Can\'t be empty'
},
}
}
}, { sequelize });