Skip to content

postgrelize / ModelValidatorFunction

Type Alias: ModelValidatorFunction ​

ModelValidatorFunction = (this, next) => unknown

Defined in: src/validation/types.ts:55

Model-level validator (validate model option); throw (or reject) to fail. Called with the instance as this. As in Sequelize v6, a validator that declares a parameter is callback style: it receives next and calls next(error) to fail or next() to pass.

Parameters ​

this ​

any

next ​

(error?) => void

Returns ​

unknown

Example ​

ts
const sync: ModelValidatorFunction = () => {
  throw new Error('invalid');
};
const callback: ModelValidatorFunction = (next) => next('invalid');

Released under the MIT License.