Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Make UUIDs valid if input is string representation or 16 byte rep #625
My database contains UUIDs in a 16 byte representation and not the string representation. The python UUID library does not automatically detect the difference if passed as the first argument, byte representations must be passed into the
This PR is to allow marshmallow to accept both the normal string representation and the byte representation.
In python 2.x bytes is the same type as string so for a valid string representation this will pass, so an additional check is made on the length being 12. For python 3.x a string representation will be a different type so the first statement will catch it.
Thanks @JeffBerger for this PR. I think this is the correct behavior. I looked into what djangorestframework does, and it looks like they only pass