Skip to content

Commit 55fd657

Browse files
authored
fix(validator): validation exception without constraint violation list
1 parent 7a9f53a commit 55fd657

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

.commitlintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"parametervalidator",
2424
"serializer",
2525
"jsonschema",
26-
"validation",
26+
"validator",
2727
"state",
2828
"test"
2929
]

src/Validator/Exception/ValidationException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class ValidationException extends RuntimeException implements ConstraintViolatio
102102
{
103103
private int $status = 422;
104104
protected ?string $errorTitle = null;
105-
private array|ConstraintViolationListInterface $constraintViolationList = [];
105+
private ConstraintViolationListInterface $constraintViolationList;
106106

107107
public function __construct(string|ConstraintViolationListInterface $message = new ConstraintViolationList(), string|int|null $code = null, int|\Throwable|null $previous = null, \Throwable|string|null $errorTitle = null)
108108
{
@@ -115,6 +115,8 @@ public function __construct(string|ConstraintViolationListInterface $message = n
115115
return;
116116
}
117117

118+
$this->constraintViolationList = new ConstraintViolationList();
119+
118120
trigger_deprecation('api_platform/core', '5.0', \sprintf('The "%s" exception will have a "%s" first argument in 5.x.', self::class, ConstraintViolationListInterface::class));
119121
parent::__construct($message ?: $this->__toString(), $code ?? 0, $previous);
120122
}

0 commit comments

Comments
 (0)