Check if a string is a UUID
See original GitHub issueDoes this library have a way to assert that a string is a valid UUID? That would be super handy for testing, especially because the way you have exposed the dependencies as raw functions makes them harder to stub. The old API uuid.v4
was easier to stub.
This much less popular uuidv4 library has the ability to check the strings: https://github.com/thenativeweb/uuidv4
I was able to test a uuidv4 generated by your lib with that libs .is() function, so that’s a perfectly good workaround, but it would be nice if it was part of your lib.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Validate UUID String in Java | Baeldung
One of the quickest ways of checking if a String is a UUID is by trying to map it using the static method...
Read more >How to judge a string is UUID type? [duplicate] - Stack Overflow
In my project, I use UUID.fromString() to convert string to UUID , but if the string is not UUID type, it will throw...
Read more >How to validate UUID String in Java - code4copy
How to validate UUID String in Java ; try {. UUID uuid = UUID.fromString(someUUID);. //do something. } ; private final static Pattern ...
Read more >Best way to check if a String is a UUID | Bukkit Forums
Hello, I'm making a method that converts all usernames into UUIDs from a configuration. Although, I need to check every key in an...
Read more >How to check if a string is a valid UUID in JavaScript?
A valid UUID should have 5 sections separated by a dash ( - ) and in the first section it should have 8...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There’s already a module for this - https://www.npmjs.com/package/uuid-validate - with download counts (~27K/month) that are 0.1% of this module (~28M/month). So… it’s not a priority. But it may get added in the future (e.g. as part of
require('uuid/utils')
or something).Tree shaking only works with ES modules. It’s not really a thing for commonJS / vanilla JS code.
How is this relevant?
Why didn’t it work for you?
The numbers suggest validation is not important to most users, not by several orders of magnitude.