You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding a sequelize-typescript's decorator to the model field, which should check that the field is not empty, validation does not work and allows you to create a record without passing this field. DB is Postgres
@Is('not-empty', (value) => {
console.log('custom decorator @Is not-empty value:', value);
if (!value) {
throw new Error('First name is required');
}
})
@Column({ validate: { notEmpty: true } })
firstName!: string;
It doesn't work too and there is no message in console.
Why walidation doesn't work?
P.S. If I send the firstName (for example) with a string length from 1 to 2 units, then the @Length({min: 3, max:30 }) validation works and an error is received.
The text was updated successfully, but these errors were encountered:
When adding a sequelize-typescript's decorator to the model field, which should check that the field is not empty, validation does not work and allows you to create a record without passing this field. DB is Postgres
Create function in client.repository.ts:
Client model:
If I try add custom validation:
It doesn't work too and there is no message in console.
Why walidation doesn't work?
P.S. If I send the firstName (for example) with a string length from 1 to 2 units, then the @Length({min: 3, max:30 }) validation works and an error is received.
The text was updated successfully, but these errors were encountered: