From 0dd9c09ab0c860c8e8acb36bb8d1da2d42dd7d3b Mon Sep 17 00:00:00 2001 From: Lukas Hroch Date: Wed, 20 Jan 2021 10:19:59 +0000 Subject: [PATCH 1/2] fix(types): allow any values in `isIn` validator --- types/lib/model.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/lib/model.d.ts b/types/lib/model.d.ts index 29c3f16c86cf..1306f97bd065 100644 --- a/types/lib/model.d.ts +++ b/types/lib/model.d.ts @@ -1093,13 +1093,13 @@ export interface ModelValidateOptions { /** * check the value is not one of these */ - notIn?: ReadonlyArray | { msg: string; args: ReadonlyArray }; + notIn?: ReadonlyArray | { msg: string; args: ReadonlyArray }; /** * check the value is one of these */ - isIn?: ReadonlyArray | { msg: string; args: ReadonlyArray }; - + isIn?: ReadonlyArray | { msg: string; args: ReadonlyArray }; + /** * don't allow specific substrings */ From c1487de2b7208db1f9fa3fc74ed3737fadccc7ab Mon Sep 17 00:00:00 2001 From: Lukas Hroch Date: Fri, 25 Jun 2021 19:17:49 +0100 Subject: [PATCH 2/2] test(types): isIn/notIn validation type tests --- types/test/validators.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 types/test/validators.ts diff --git a/types/test/validators.ts b/types/test/validators.ts new file mode 100644 index 000000000000..56254de307db --- /dev/null +++ b/types/test/validators.ts @@ -0,0 +1,22 @@ +import { DataTypes, Model, Sequelize } from 'sequelize'; + +const sequelize = new Sequelize('mysql://user:user@localhost:3306/mydb'); + +/** + * Test for isIn/notIn validation - should accept any[] + */ +class ValidatedUser extends Model {} +ValidatedUser.init({ + name: { + type: DataTypes.STRING, + validate: { + isIn: [['first', 1, null]] + } + }, + email: { + type: DataTypes.STRING, + validate: { + notIn: [['second', 2, null]] + } + }, +}, { sequelize }); \ No newline at end of file