coduo/php-matcher

UUID matcher throws error for NIL uuid

knyk opened this issue · 8 comments

knyk commented

for uuid 00000000-0000-0000-0000-000000000000 it is throwing an error

hmm because it's not valid uuid? Can you be more precise and tell me what kind of error and what is the behavior that you expect?

knyk commented

it is valid uuid for sure. look at RFC https://tools.ietf.org/html/rfc4122#section-4.1.7

No, it's not valid uuid because you can't generate it - it's special type of uuid and I would like to understand the use case in which matcher should support if you expect from me to fix it.

knyk commented

I really can't find the place in RFC where it is written that NIL uuid is not valid uuid to be honest.
The use case is It is very easy to use uuid just by using constant Ramsey\Uuid::NIL. You can use It for example in doctrine fixtures and then in easy cases You don't need to think and check what was the uuid i've used in that fixture - just use const from Ramsey

No, it's not valid uuid because you can't generate it

Ramsey\Uuid::isValid return true for It and I'am pretty sure that symfony uuid constraint too

I would recommend you to not use NIL uuid and just generate one instead because like I said, it's not type of UUID that can be generated (you won't get it from any api).
However if you really need support for NIL uuid then feel free to open PR

knyk commented

I'am using NILs for a long time for for testing purposes without any false positives and so on.
Trust me, there are many types of APIs, not all of them implements uuid the right way.

For now case is not crucial for me. Maybe later when I would have some free time

Trust me, there are many types of APIs, not all of them implements uuid the right way.

maybe but it's not a valid scenario that would make me to invest my private time to fix "bug" that affects only wrong usages of the UUID.
I'm closing this issue for now, feel free to open a PR whenever you find time, thanks!

Hi. This just bit me when matching some data in my JSON documents. We use a NIL UUID as a perfectly valid UUID which denotes a root of a tree of some data and PHP Matcher cannot work with it when using @uuid@ matcher.