Skip to content

Commit f00862e

Browse files
authored
Merge pull request #5 from Insolita/validation-fix
Allow string-numeric ids for integer idType
2 parents 1a958d3 + 0eda337 commit f00862e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/RelationshipManager.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use function count;
2222
use function gettype;
2323
use function implode;
24+
use function is_numeric;
2425

2526
/**
2627
* @see https://jsonapi.org/format/#crud-updating-to-one-relationships
@@ -278,7 +279,9 @@ protected function validateIdType(array $ids, bool $allowNull = false):void
278279
{
279280
foreach ($ids as $id) {
280281
$type = gettype($id);
281-
if (($type === $this->idType) || ($allowNull && $type === 'NULL')) {
282+
if (($this->idType === 'integer' && is_numeric($id))
283+
||($type === $this->idType)
284+
|| ($allowNull && $type === 'NULL')) {
282285
continue;
283286
}
284287
throw new HttpException(422, 'Data contains ids with invalid type');

0 commit comments

Comments
 (0)