You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently trying to implement a simple denormalizer for API platform that allows invalid UUID values like "abc" to hit the validator of the DTO property path instead of producing a hard "The input data is misformatted." exception. First I thought it might be a quirk within the vendor, but simplifying it to the following shows some unexpected behavior:
Using symfony/uids own commands I get the following:
So I'm unsure about the following points, maybe I'm missing something and this all expected:
I see there is an attempt to satisfy the RFC by juggling a second parameter, but I do not understand why it would matter that early in the code, because a developer should be able to pass any valid-encoded value and the implementation is very strict about the encodings that can go in.
Then the whole process breaks at the point where Ulid::isValid is used within Uuid::transformToRfc9562. What is the whole && $format & self::FORMAT_BASE_32 part protecting against, and why are we handling a Ulid all of the sudden?
A similar question was raised in #45148 but with no real outcome.
How to reproduce
See description for simple code snippets.
Possible Solution
During development I expected the following given:
Uuid:isValid should validate any encoding, and fail ULIDs and invalid values.
Ulid::isValid should validate any encoding and fail UUIDs and invalid values.
As for the vendors weird behavior:
UidNormalizer should be split into UuidNormalizer and UlidNormalizer if there is such a stark contrast between both and not be based on the abstract. This split is also done on the validator constraints as well.
UidNormalizer could use RFC 9562s NilUuid as an indication that there is no processable value there, allowing the Uuid constraint to actually fail (NilUuid is invalid) instead of the de/normalizer beforehand.
Additional Context
No response
The text was updated successfully, but these errors were encountered:
After a round-trip through the RFCs and docs, I'll close this. Reading the 7.2 docs I see now that Uuid::FORMAT_ALL was introduced as a second parameter to isValid in a way that does not use PHP function signature with default values, but a magical variant that hides it from IDEs. Not sure why, but that solves it.
Symfony version(s) affected
7.2
Description
I'm currently trying to implement a simple denormalizer for API platform that allows invalid UUID values like "abc" to hit the validator of the DTO property path instead of producing a hard "The input data is misformatted." exception. First I thought it might be a quirk within the vendor, but simplifying it to the following shows some unexpected behavior:
Using symfony/uids own commands I get the following:
yet simple validation checks seem to be all over the place:
So I'm unsure about the following points, maybe I'm missing something and this all expected:
I see there is an attempt to satisfy the RFC by juggling a second parameter, but I do not understand why it would matter that early in the code, because a developer should be able to pass any valid-encoded value and the implementation is very strict about the encodings that can go in.
Then the whole process breaks at the point where Ulid::isValid is used within
Uuid::transformToRfc9562
. What is the whole&& $format & self::FORMAT_BASE_32
part protecting against, and why are we handling a Ulid all of the sudden?A similar question was raised in #45148 but with no real outcome.
How to reproduce
See description for simple code snippets.
Possible Solution
During development I expected the following given:
Uuid:isValid
should validate any encoding, and fail ULIDs and invalid values.Ulid::isValid
should validate any encoding and fail UUIDs and invalid values.As for the vendors weird behavior:
Additional Context
No response
The text was updated successfully, but these errors were encountered: