Skip to content

fix(core): allow 'all' as isUUID validator argument#18200

Open
cyphercodes wants to merge 1 commit intosequelize:mainfrom
cyphercodes:fix-isuuid-type-18171
Open

fix(core): allow 'all' as isUUID validator argument#18200
cyphercodes wants to merge 1 commit intosequelize:mainfrom
cyphercodes:fix-isuuid-type-18171

Conversation

@cyphercodes
Copy link
Copy Markdown

@cyphercodes cyphercodes commented Apr 5, 2026

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:

  • The simple form: isUUID: 'all'
  • The object form: isUUID: { msg: string; args: number | 'all' }

Issue Reference

Fixes #18171

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Testing

Added TypeScript type tests in test/types/validators.ts to verify that both isUUID: 4 and isUUID: 'all' are accepted by the type checker.

Checklist

  • I have read the contribution guidelines
  • This change follows the project's coding style
  • I have added tests that verify the type change works correctly

Summary by CodeRabbit

  • New Features
    • UUID validator now accepts 'all' to validate against all UUID versions.
    • UUID validator object form now supports 'all' as an argument value alongside numeric precision options.

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
@cyphercodes cyphercodes requested a review from a team as a code owner April 5, 2026 15:48
@cyphercodes cyphercodes requested review from ephys and sdepold April 5, 2026 15:48
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 5, 2026

📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Type Definition Update
packages/core/src/model.d.ts
Added support for 'all' string literal to ColumnValidateOptions.isUUID, allowing both direct usage and within the { msg, args } configuration object where args now accepts number | 'all'.
Test Coverage
packages/core/test/types/validators.ts
Introduced new UserWithUUID test model with three attributes validating different isUUID forms: numeric value (4), string literal ('all'), and object configuration with custom message and args: 'all'.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • sdepold
  • ephys

Poem

🐰 A UUID validator so fine,
Now accepts 'all' in its design,
Types aligned, tests run true,
Every version shines through! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR fully addresses issue #18171 by updating ColumnValidateOptions.isUUID type to accept 'all' in both simple and object forms, and includes test cases validating the new type support.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the isUUID validator type definition and adding corresponding test coverage; no extraneous modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely summarizes the main change: allowing 'all' as a valid argument to the isUUID validator. It directly addresses the primary purpose of the PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

* only allow uuids
*/
isUUID?: number | { msg: string; args: number };
isUUID?: number | 'all' | { msg: string; args: number | 'all' };
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we import from @types/validator?

@ephys ephys changed the title fix(types): allow 'all' as isUUID validator argument fix(core): allow 'all' as isUUID validator argument Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type for isUUID validator is missing support for 'all'

2 participants