-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
uuid4 and uuid4_rfc4122 failing with postgres uuids #902
Comments
I'm dumb. Didn't realize I needed to use dive on it. |
@FM1337 If you look closely at your code you will see you are trying to apply the uuid validation against the type []string which is why it is correctly failing. If you wish to apply a validation to the inner values of an array/slice you must call dive first |
Ah beat me to it. |
@deankarn yeah sorry about that, walking away to get some lunch helped clear my mind and figure the issue out. Nothing in the README.md though mentioning to use |
Happy to accept a PR to improve the docs. it may not be in the README but it should be in the godocs and in one of the examples as well. |
Package version eg. v9, v10:
v10 (v10.10.0)
Issue, Question or Enhancement:
I have two UUIDs here generated by Postgres
I attempted to validate using the
uuid4
format rule, but after that didn't work, I trieduuid4_rfc4122
, and neither one passed validationCode sample, to showcase or reproduce:
I attempted upper casing them for rfc4122 as well, as according to the docs
This validates that a string value contains a valid version 4 UUID. Uppercase UUID values will not pass - use uuid4_rfc4122 instead.
I tried both form-data, x-www-form-urlencoded and in json as the data sent to the server, and even though it successfully decodes each time, it always fails validation on those rules.
(Errors outputted)
I decoded them online to verify their versioning
I understand that there's already another issue like this open, #900 but that's attempting to use the google.UUID library, whereas I'm simply treating it as a string.
This is the output of the parsed struct I'm trying to validate
So there's nothing wrong with how I'm receiving the data from the HTTP request, and it appears to be some issues with some of the validation rules (also noticed an issue with datetime but that's for another issue, not this one)
Also according to postgres docs:
The data type uuid stores Universally Unique Identifiers (UUID) as defined by RFC 4122, ISO/IEC 9834-8:2005, and related standards.
The UUIDs were generated using gen_random_uuid()
The text was updated successfully, but these errors were encountered: