fix(core): allow 'all' as isUUID validator argument#18200
fix(core): allow 'all' as isUUID validator argument#18200cyphercodes wants to merge 1 commit intosequelize:mainfrom
Conversation
The isUUID field validator accepts both number (1, 2, 3, 4, 5, 7)
and the string 'all' as valid arguments, but the TypeScript type
definition only allowed number.
This fix updates the type to include 'all' as a valid option for
both the simple form (isUUID: 'all') and the object form
(isUUID: { msg: string; args: number | 'all' }).
Fixes sequelize#18171
📝 WalkthroughWalkthroughThe isUUID validator type definition is updated to accept the 'all' string value directly and within error configuration objects. Test coverage is added for the newly supported string literal form alongside existing numeric validation cases. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| * only allow uuids | ||
| */ | ||
| isUUID?: number | { msg: string; args: number }; | ||
| isUUID?: number | 'all' | { msg: string; args: number | 'all' }; |
There was a problem hiding this comment.
Shouldn't we import from @types/validator?
Description of Changes
The isUUID field validator accepts both number (1, 2, 3, 4, 5, 7) and the string 'all' as valid arguments, but the TypeScript type definition only allowed number.
This PR updates the type to include 'all' as a valid option for both:
isUUID: 'all'isUUID: { msg: string; args: number | 'all' }Issue Reference
Fixes #18171
Type of Change
Testing
Added TypeScript type tests in
test/types/validators.tsto verify that bothisUUID: 4andisUUID: 'all'are accepted by the type checker.Checklist
Summary by CodeRabbit
'all'to validate against all UUID versions.'all'as an argument value alongside numeric precision options.