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
enum Location: string
{
case GOE = 'GOE';
case HAN = 'HAN';
}
Now I got a data class like this:
final class LocationData extends Data
{
public function __construct(
public readonly int $id,
public readonly Location $name,
) {}
}
Now I want to make sure that Location is validated correctly (works), but also to ensure that a given value like han will be transformed to uppercase before validation. This does not work with a transformer.
Is there any chance I can do that? I cannot simply touch the enum itself (unfortunately).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I got this enum
Now I got a data class like this:
Now I want to make sure that Location is validated correctly (works), but also to ensure that a given value like
han
will be transformed to uppercase before validation. This does not work with a transformer.Is there any chance I can do that? I cannot simply touch the enum itself (unfortunately).
Beta Was this translation helpful? Give feedback.
All reactions