fix(types): allow any values in isIn validator#12962
Conversation
papb
left a comment
There was a problem hiding this comment.
Hello! I see you are a first-time contributor, thank you for taking the time to help Sequelize! I hope to see more PRs from you in the future!
Please add at least one test to make sure your implementation works as intended and to prevent regressions in the future. For good examples on how to test typescript typings, check the following PRs: 11368, 11379, 11520, 13042. You can also use expect-type if you need more complex assertions for your test.
|
No problem, added couple of tests. I haven't found any other tests for validators (type tests looks bit random), so hope this place is OK. Let me know if anything needs amending. |
| email: { | ||
| type: DataTypes.STRING, | ||
| validate: { | ||
| notIn: [['second', 2, null]] |
There was a problem hiding this comment.
I would have somehow expected that we would have e.g. an INTEGER column and hence verify that the value is no part of a list of numbers or so.
Also, is that syntax correct? Why array of array and not ['first', 1, null]
There was a problem hiding this comment.
test was written to demonstrate that type works, i.e. it accepts other types not just string. Real world would be different, as you say e.g. list of int and int data type.
Syntax is how sequelize implements it (https://github.com/sequelize/sequelize/blob/main/types/lib/model.d.ts#L1112 or https://sequelize.org/master/manual/validations-and-constraints.html), I haven't really change that. Just a type since validator.js allows any for this validation.
|
🎉 This PR is included in version 6.8.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* fix(types): allow any values in `isIn` validator * test(types): isIn/notIn validation type tests Co-authored-by: Sascha Depold <sdepold@users.noreply.github.com>
Pull Request check-list
Please make sure to review and check all of these items:
npm run testornpm run test-DIALECTpass with this change (including linting)?Description of change
Hi,
this is to update current types for
isInvalidator of validator.js lib. It should accept array of any values. It is then coerced to string regardless the content.It updates both
isInandnotInsignatures are both are using validator.jsisIn.This is e.g. useful when model's column is number and you're validating against list of numbers.
Reference: