Skip to content

fix(isUUID)!: fully support rfc9562 - #2421

Merged
profnandaa merged 1 commit into
validatorjs:masterfrom
broofa:uuid_rfc9562
Jun 22, 2024
Merged

profnandaa merged 1 commit into
validatorjs:masterfrom
broofa:uuid_rfc9562

Conversation

@broofa

@broofa broofa commented Jun 13, 2024 •

Copy link
Copy Markdown
Contributor

PR for #2419.

Note that this will be a BREAKING CHANGE for the following reasons:

  • isUUID(str, version) will now return false if str does not have a valid variant field. (Previously only versions 4, 5, and 7 enforced this field.)
  • isUUID(str, 'all') now only allows RFC9562 UUIDS. Previously it would accept any string that looked UUID-ish ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), regardless of what values were in the version or variant fields.

provide some (credible) references showing the structure of the data to be validated, if applicable

New UUID values were generated with the uuid utility. E.g. npx uuid v6. Also, I maintain the uuid module so... 🤷

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)
  • References provided in PR (where applicable)

Comment thread test/validators.test.js Resolved
@rubiin

rubiin commented Jun 22, 2024

Copy link
Copy Markdown
Member

@profnandaa this is a critical fix considering we were allowing invalid uuids in the past

@profnandaa profnandaa left a comment

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.

LGTM, thanks for the fix!

@profnandaa
profnandaa merged commit 89e856c into validatorjs:master Jun 22, 2024
@bc-m bc-m mentioned this pull request May 15, 2025
superfortune-passion pushed a commit to superfortune-passion/validator.js that referenced this pull request May 31, 2026
otnc added a commit to otnc/nest that referenced this pull request Sep 14, 2026
ParseUUIDPipe without a version only checked the 8-4-4-4-12 shape, so values
whose version nibble is outside 1-8 or whose variant nibble is not 10xx passed.

The all pattern now follows RFC 9562 the same way validator.js does since
validatorjs/validator.js#2421: versions 1-8 with the RFC variant, plus the
Nil and Max UUIDs.
otnc added a commit to otnc/nest that referenced this pull request Sep 14, 2026
ParseUUIDPipe without a version only checked the 8-4-4-4-12 shape, so values
whose version nibble is outside 1-8 or whose variant nibble is not 10xx passed.

The all pattern now follows RFC 9562 the same way validator.js does since
validatorjs/validator.js#2421: versions 1-8 with the RFC variant, plus the
Nil and Max UUIDs.
kamilmysliwiec pushed a commit to nestjs/nest that referenced this pull request Sep 15, 2026
…#17738)

ParseUUIDPipe without a version only checked the 8-4-4-4-12 shape, so values
whose version nibble is outside 1-8 or whose variant nibble is not 10xx passed.

The all pattern now follows RFC 9562 the same way validator.js does since
validatorjs/validator.js#2421: versions 1-8 with the RFC variant, plus the
Nil and Max UUIDs.
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.

3 participants