ValidationException
How To use ValidationException ?
Status Code 400
Usage
With custom configuration
...
function validate(model) {
const errors: IException = [];
...
if (!model?.name) {
errors.push({
code: 'NAME_REQUIRED',
message: 'name is required',
fields: ['name'],
})
}
...
if (model.password.length < 8) {
errors.push({
code: 'PASSWORD_MIN_LENGTH',
message: 'password must be at least 8 characters',
fields: ['password'],
})
}
...
if (errors.length > 0) {
throw new ValidationException(errors);
}
}
validate(model)
...