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

String UUID validation via a regex #909

Merged
merged 2 commits into from
Jun 16, 2020
Merged

String UUID validation via a regex #909

merged 2 commits into from
Jun 16, 2020

Conversation

LFabre
Copy link
Contributor

@LFabre LFabre commented May 25, 2020

String UUID validation via a regex.

  • Adds a new validation method to String schemas.
  • This new method allows UUID validation via a regex.
  • Empty strings are not allowed since they are not a valid UUID.

The regex used to validate an UUID was taken from the project uuidv4.
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i

For the test cases valid UUIDs were generated using uuidv4.

@azizur
Copy link

azizur commented Jun 13, 2020

Any update when this will be merged?

@LFabre
Copy link
Contributor Author

LFabre commented Jun 16, 2020

I hope it can be merged soon.
Nice to see other people interested on this feature as well.

@jquense jquense merged commit 8f2bd2b into jquense:master Jun 16, 2020
@jquense
Copy link
Owner

jquense commented Jun 16, 2020

thanks! generally we aren't adding new regex shortcuts but i agree that this one is useful and common enough to warrant inclusion. thanks for the work!

@buzinas
Copy link

buzinas commented Jul 17, 2020

@jquense I'd be very glad if you were able to release a npm version including this, thanks!

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.

None yet

4 participants