Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update isUUID() to fully support the new UUID spec (RFC9562) #2419

Open
4 tasks
broofa opened this issue Jun 13, 2024 · 4 comments
Open
4 tasks

Update isUUID() to fully support the new UUID spec (RFC9562) #2419

broofa opened this issue Jun 13, 2024 · 4 comments

Comments

@broofa
Copy link
Contributor

broofa commented Jun 13, 2024

[Related to #2344.]

Hi, uuid maintainer here. I happened to notice this project while perusing open issues on the DefinitelyTyped project. The UUID spec has been updated for the first time in almost 20 years, which is where the new v7 UUID comes from (support added here in #2344). However, there's more to the new RFC than just version 7. I also noticed a couple other issues while glancing at the isUUID() code here.

Specifically, to be fully RFC9562-compliant will require the following:

  • Add support for version 6 and version 8 UUIDS. The new UUID RFC (RFC9562) adds two new versions, in addition to version 7 (which this library already supports. Version 6 ("improved version 1 layout") and version 8 ("experimental") are now also valid versions
  • Enforce variant field for all versions. It's weird that it's only enforced for versions 4, 5, and 7.
  • Add support for NIL and MAX UUIDs. For completeness, I would expect the uuid regexs to include nil and max patterns.
  • Use a better regex for all. For example, here's the regex we use for uuid.
@rubiin
Copy link
Member

rubiin commented Jun 13, 2024

Thanks for the headsup and detailed analaysis :) will look into it on free time

@rubiin
Copy link
Member

rubiin commented Jun 13, 2024

@broofa
I used the all regex , but this doesnt seem to validate a UUID which was of type v3
https://regex101.com/r/r3roG6/1
image

@broofa
Copy link
Contributor Author

broofa commented Jun 13, 2024

@broofa I used the all regex , but this doesnt seem to validate a UUID which was of type v3

@rubin Yeah, several of the "valid" UUIDs in the tests aren't actually valid. They have a bad variant field. (tl;dr: str[19] can only contain an 8, 9, a or b). See the changes I made in the PR I put up. Hopefully that explains what's wrong here.

@rubiin
Copy link
Member

rubiin commented Jun 13, 2024

Got it. I have approved the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants