Skip to content

Commit 3583931

Browse files
committed
fix: throw a ValidationException
1 parent 5ba7c7c commit 3583931

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/validation.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,10 @@ final readonly class MyEntityRemoveProcessor implements ProcessorInterface
419419

420420
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = [])
421421
{
422-
$validationErrors = $this->validator->validate($data, groups: ['deleteValidation']]);
423-
if($validationErrors->count() > 0) {
424-
//trigger some error / throw some exception...for example
425-
throw new ConflictHttpException($errors->get(0)->getMessage());
422+
$violations = $this->validator->validate($data, groups: ['deleteValidation']]);
423+
if(0 !== \count($violations)) {
424+
//trigger some error / throw some exception...for example :
425+
throw new ValidationException($violations);
426426
}
427427
$this->doctrineProcessor->process($data, $operation, $uriVariables, $context);
428428
}

0 commit comments

Comments
 (0)