Skip to content

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.

1 participant