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

UUID Logical Type Support #257

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

noahwill
Copy link

@noahwill noahwill commented Sep 12, 2022

I've encountered a case where it would have been helpful to validate that a string in a field, {"type": ["null", {"type": "string", "logicalType": "uuid"}], "default": null}, was in fact a uuid.

To accomplish this, I've added two functions: nativeFromUUID and uuidFromNative. Both of these functions use uuid.Parse to validate that an outgoing or incoming string is a UUID. I went this route rather than using a regex because I found a gist that showed that google's uuid.Parse was much faster. Hopefully, the project is not too opposed to introducing a new package, but I am happy to hear objections.

Please let me know if there's any changes I should make; I hope this is a useful contribution!

use uuid.Parse() to ensure that a string received
in a field with logicalType 'uuid' is truly a valid
uuid
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

1 participant