forked from api-platform/core
/
ValidationException.php
69 lines (64 loc) · 2.71 KB
/
ValidationException.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <dunglas@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace ApiPlatform\Symfony\Validator\Exception;
use ApiPlatform\JsonLd\ContextBuilderInterface;
use ApiPlatform\Metadata\Error as ErrorOperation;
use ApiPlatform\Metadata\ErrorResource;
use ApiPlatform\Metadata\Exception\HttpExceptionInterface;
use ApiPlatform\Metadata\Exception\ProblemExceptionInterface;
use ApiPlatform\Validator\Exception\ConstraintViolationListAwareExceptionInterface as ApiPlatformConstraintViolationListAwareExceptionInterface;
use ApiPlatform\Validator\Exception\ValidationException as BaseValidationException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface as SymfonyHttpExceptionInterface;
use Symfony\Component\WebLink\Link;
/**
* Thrown when a validation error occurs.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @deprecated since API Platform 3.3, use {@see BaseValidationException} instead
*/
#[ErrorResource(
uriTemplate: '/validation_errors/{id}',
status: 422,
openapi: false,
uriVariables: ['id'],
provider: 'api_platform.validator.state.error_provider',
shortName: 'ConstraintViolationList',
operations: [
new ErrorOperation(
name: '_api_validation_errors_problem',
outputFormats: ['json' => ['application/problem+json']],
normalizationContext: ['groups' => ['json'],
'skip_null_values' => true,
'rfc_7807_compliant_errors' => true,
]
),
new ErrorOperation(
name: '_api_validation_errors_hydra',
outputFormats: ['jsonld' => ['application/problem+json']],
links: [new Link(rel: ContextBuilderInterface::JSONLD_NS.'error', href: 'http://www.w3.org/ns/hydra/error')],
normalizationContext: [
'groups' => ['jsonld'],
'skip_null_values' => true,
'rfc_7807_compliant_errors' => true,
]
),
new ErrorOperation(
name: '_api_validation_errors_jsonapi',
outputFormats: ['jsonapi' => ['application/vnd.api+json']],
normalizationContext: ['groups' => ['jsonapi'], 'skip_null_values' => true, 'rfc_7807_compliant_errors' => true]
),
],
graphQlOperations: []
)]
final class ValidationException extends BaseValidationException implements ConstraintViolationListAwareExceptionInterface, ApiPlatformConstraintViolationListAwareExceptionInterface, \Stringable, ProblemExceptionInterface, HttpExceptionInterface, SymfonyHttpExceptionInterface
{
}