validatorjs / validator.js

String validation
MIT License
23.12k stars 2.31k forks source link

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

Open broofa opened 4 months ago

broofa commented 4 months ago

[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:

rubiin commented 4 months ago

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

rubiin commented 4 months ago

@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 commented 4 months ago

@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 commented 4 months ago

Got it. I have approved the PR