diff --git a/src/Schema/Elements/AnyOf.php b/src/Schema/Elements/AnyOf.php index ab75fbc..b4ce465 100644 --- a/src/Schema/Elements/AnyOf.php +++ b/src/Schema/Elements/AnyOf.php @@ -73,7 +73,7 @@ public function complete($value, Nette\Schema\Context $context) if ($item instanceof Schema) { $dolly = new Context; $dolly->path = $context->path; - $res = $item->complete($value, $dolly); + $res = $item->complete($item->normalize($value, $dolly), $dolly); if (!$dolly->errors) { return $this->doFinalize($res, $context); } diff --git a/tests/Schema/Expect.anyOf.phpt b/tests/Schema/Expect.anyOf.phpt index 379e1d8..99792fa 100644 --- a/tests/Schema/Expect.anyOf.phpt +++ b/tests/Schema/Expect.anyOf.phpt @@ -200,3 +200,11 @@ test('Schema as default value', function () { Assert::same(['key1' => ['key2' => null]], (new Processor)->process($schema, null)); }); + + +test('normalization', function () { + $schema = Expect::anyOf( + Expect::string()->before(function ($v) { return (string) $v; }) + ); + Assert::same('1', (new Processor)->process($schema, 1)); +});