question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Check if a string is a UUID

See original GitHub issue

Does 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:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
broofacommented, Dec 19, 2017

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).

0reactions
broofacommented, Jun 14, 2019

tree shaking means that any util exports won’t be needlessly packaged

Tree shaking only works with ES modules. It’s not really a thing for commonJS / vanilla JS code.

uuid standards don’t change, so once the utilities are set up they won’t require any extra maintenance.

How is this relevant?

yes, I’m aware of the other package and tried it out…

Why didn’t it work for you?

but it might even be important to even encourage the use of a validator along with your generation tools, as UUIDs are often used as arguments in HTTP calls.

The numbers suggest validation is not important to most users, not by several orders of magnitude.

image image

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found