Skip to content

Commit

Permalink
misc: chance union error message
Browse files Browse the repository at this point in the history
  • Loading branch information
romm committed Mar 17, 2024
1 parent 2dc3186 commit c6f0ab6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Mapper/Tree/Exception/TooManyResolvedTypesFromUnion.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function __construct(UnionType $unionType)
];

$this->body = TypeHelper::containsObject($unionType)
? 'Invalid value {source_value}, it matches at least two types from union.'
: 'Invalid value {source_value}, it matches at least two types from {allowed_types}.';
? 'Invalid value {source_value}, it matches two or more types from union.'
: 'Invalid value {source_value}, it matches two or more types from {allowed_types}.';

parent::__construct(StringFormatter::for($this), 1710262975);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Integration/Mapping/UnionMappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public function test_scalar_value_matching_two_objects_in_union_throws_exception
$error = $exception->node()->messages()[0];

self::assertSame('1710262975', $error->code());
self::assertSame("Invalid value 'foo', it matches at least two types from union.", (string)$error);
self::assertSame("Invalid value 'foo', it matches two or more types from union.", (string)$error);
}
}

Expand All @@ -274,7 +274,7 @@ public function test_array_value_matching_two_objects_in_union_throws_exception(
$error = $exception->node()->messages()[0];

self::assertSame('1710262975', $error->code());
self::assertSame("Invalid value array{string: 'foo'}, it matches at least two types from union.", (string)$error);
self::assertSame("Invalid value array{string: 'foo'}, it matches two or more types from union.", (string)$error);
}
}

Expand All @@ -293,7 +293,7 @@ public function test_array_value_matching_two_arrays_in_union_throws_exception()
$error = $exception->node()->messages()[0];

self::assertSame('1710262975', $error->code());
self::assertSame("Invalid value array{0: 'foo', 1: 'bar'}, it matches at least two types from `array<string>`, `array<'foo'|'bar'>`.", (string)$error);
self::assertSame("Invalid value array{0: 'foo', 1: 'bar'}, it matches two or more types from `array<string>`, `array<'foo'|'bar'>`.", (string)$error);
}
}

Expand All @@ -312,7 +312,7 @@ public function test_array_value_matching_array_shape_and_object_in_union_throws
$error = $exception->node()->messages()[0];

self::assertSame('1710262975', $error->code());
self::assertSame("Invalid value array{string: 'foo'}, it matches at least two types from union.", (string)$error);
self::assertSame("Invalid value array{string: 'foo'}, it matches two or more types from union.", (string)$error);
}
}
}
Expand Down

0 comments on commit c6f0ab6

Please sign in to comment.