Skip to content

Commit a12a403

Browse files
committed
Revert "Add check for required properties in error objects"
This reverts commit c28e2a1. See json-api/json-api#1525 (comment)
1 parent 8cc6d02 commit a12a403

File tree

3 files changed

+0
-32
lines changed

3 files changed

+0
-32
lines changed

CHANGELOG.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
- Dropped support for PHP 7.4 and PHP 8.0
1313

14-
### Fixed
15-
16-
- Add check that an error object contains at least one of `id`, `links`, `status`, `code`, `title`, `detail`, `source` or `meta`.
17-
1814
### Deprecated
1915

2016
- `\Art4\Accessable::get()` will add `mixed` as a native return type declaration in 2.0.0, do the same in your implementation now to avoid errors.

src/V1/Error.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ protected function parse(mixed $object): void
3333
);
3434
}
3535

36-
if (!property_exists($object, 'id') and !property_exists($object, 'links') and !property_exists($object, 'status') and !property_exists($object, 'code') and !property_exists($object, 'title') and !property_exists($object, 'detail') and !property_exists($object, 'source') and !property_exists($object, 'meta')) {
37-
throw new ValidationException('An error object MUST contain at least one of: `id`, `links`, `status`, `code`, `title`, `detail`, `source` or `meta`.');
38-
}
39-
4036
if (property_exists($object, 'id')) {
4137
if (!is_string($object->id)) {
4238
throw new ValidationException(

tests/Unit/V1/ErrorTest.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -161,28 +161,4 @@ public function testCreateDetailWithoutStringThrowsException(mixed $input): void
161161

162162
$error = new Error($object, $this->manager, $this->parent);
163163
}
164-
165-
/**
166-
* An error object MAY have the following members, and MUST contain at least one of:
167-
* - id
168-
* - links
169-
* - status
170-
* - code
171-
* - title
172-
* - details
173-
* - source
174-
* - meta
175-
*/
176-
public function testCreateWithoutRequiredPropertiesThrowsException(): void
177-
{
178-
$object = new \stdClass();
179-
$object->description = 'error description';
180-
181-
$this->expectException(ValidationException::class);
182-
$this->expectExceptionMessage(
183-
'An error object MUST contain at least one of: `id`, `links`, `status`, `code`, `title`, `detail`, `source` or `meta`.'
184-
);
185-
186-
$error = new Error($object, $this->manager, $this->parent);
187-
}
188164
}

0 commit comments

Comments
 (0)