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
With the current AbstractUid contract we can output different "formats" by calling dedicated methods: toBase58(), toBase32(), toRfc4122() and toBinary(). However, when we want to convert back a string uid to its object we can only use the fromString() method (that method handle all the possible formats one by one).
I think it would be more convenient to add dedicated methods for the "from" action too. You could use them when you know the input format and want to restrict it. Currently, in my code, I have to do:
if (22 !== strlen($base58Ulid)) {
throw new \InvalidArgumentException();
}
before any call to Ulid::fromString($base58Ulid) because I do not want to support (accidentally) the case where $base58Ulid would actually contain the rfc 4122 version for example. I would prefer to use Ulid::fromBase58($base58Ulid) and let Symfony handle the validation 🤷♂️ Does that make sense?
The text was updated successfully, but these errors were encountered:
With the current
AbstractUid
contract we can output different "formats" by calling dedicated methods:toBase58()
,toBase32()
,toRfc4122()
andtoBinary()
. However, when we want to convert back a string uid to its object we can only use thefromString()
method (that method handle all the possible formats one by one).I think it would be more convenient to add dedicated methods for the "from" action too. You could use them when you know the input format and want to restrict it. Currently, in my code, I have to do:
before any call to
Ulid::fromString($base58Ulid)
because I do not want to support (accidentally) the case where$base58Ulid
would actually contain the rfc 4122 version for example. I would prefer to useUlid::fromBase58($base58Ulid)
and let Symfony handle the validation 🤷♂️ Does that make sense?The text was updated successfully, but these errors were encountered: