website
website copied to clipboard
Fix code in `validations-and-constraints.md`
Two kinds of errors here:
-
Sequelize.STRINGandSequelize.INTEGERdon't exist. These should beDataTypes.STRINGandDataTypes.INTEGERinstead. - TypeScript assumes that
thiscorresponds to theModelValidateOptionsthat the validation method is defined in.
In a TypeScript file, we would write
User.init({
// ...,
validate: {
customValidator(this: User, value: string | null) {
// ...
}
}
})
But your examples are in JS, so I'm writing a JSDoc equivalent. While I wouldn't usually force types upon people who choose to write untyped code, this is a special case. Without this, the people who do choose to use types will otherwise see the wrong type here.