@@ -668,7 +668,7 @@ private static function unionTypeDecide(array $unionType, mixed $value): mixed
668668 foreach ($ unionType ['types ' ] as $ type ) {
669669 try {
670670 return self ::valueDecide ($ type , $ value );
671- } catch (InvalidValueException | ValidationChainException | InvalidEnumValueException ) {
671+ } catch (InvalidValueException | ValidationChainException | InvalidEnumValueException | RequiredValueException ) {
672672 continue ;
673673 }
674674 }
@@ -697,12 +697,12 @@ private static function valueDecide(array $type, mixed $value): mixed
697697 $ typename = $ type ['typename ' ]['string ' ];
698698 if (!$ type ['isBuiltin ' ]) {
699699 return match (true ) {
700- $ value instanceof $ typename => $ value ,
701- (\is_string ($ value ) || \is_int ($ value )) && $ type ['isEnum ' ] => self ::analyzeEnum ($ typename , $ value ),
702- \is_array ($ value ) && is_a ($ typename , self ::class, true ) => $ typename ::fromArray ($ value ),
703- is_a ($ typename , SingleValueObject::class, true ) && !\is_object ($ value ) => $ typename ::from ($ value ),
700+ $ value instanceof $ typename => $ value ,
701+ (\is_string ($ value ) || \is_int ($ value )) && $ type ['isEnum ' ] => self ::analyzeEnum ($ typename , $ value ),
702+ \is_array ($ value ) && is_a ($ typename , self ::class, true ) => $ typename ::fromArray ($ value ),
703+ is_a ($ typename , SingleValueObject::class, true ) && !\is_object ($ value ) => $ typename ::from ($ value ),
704704 \is_string ($ value ) && self ::jsonLike ($ value ) && is_a ($ typename , self ::class, true ) => $ typename ::fromJson ($ value ),
705- default => throw new InvalidValueException ($ typename , $ value ),
705+ default => throw new InvalidValueException ($ typename , $ value ),
706706 };
707707 }
708708 if (
0 commit comments