Skip to content

Commit

Permalink
fix(symfony): use Type constraint violation code instead of exception…
Browse files Browse the repository at this point in the history
… code (#6037)
  • Loading branch information
norkunas authored Dec 19, 2023
1 parent a9a0689 commit aae0dbf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/EventListener/DeserializeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function onKernelRequest(RequestEvent $event): void
if ($exception->canUseMessageForUser()) {
$parameters['hint'] = $exception->getMessage();
}
$violations->add(new ConstraintViolation($this->translator->trans($message, ['{{ type }}' => implode('|', $exception->getExpectedTypes() ?? [])], 'validators'), $message, $parameters, null, $exception->getPath(), null, null, (string) $exception->getCode()));
$violations->add(new ConstraintViolation($this->translator->trans($message, ['{{ type }}' => implode('|', $exception->getExpectedTypes() ?? [])], 'validators'), $message, $parameters, null, $exception->getPath(), null, null, Type::INVALID_TYPE_ERROR));
}
if (0 !== \count($violations)) {
throw new ValidationException($violations);
Expand Down
2 changes: 1 addition & 1 deletion tests/Symfony/EventListener/DeserializeListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public function testTurnPartialDenormalizationExceptionIntoValidationException()
$this->assertSame($violation->getPropertyPath(), 'foo');
$this->assertNull($violation->getInvalidValue());
$this->assertNull($violation->getPlural());
$this->assertSame($violation->getCode(), '0');
$this->assertSame($violation->getCode(), 'ba785a8c-82cb-4283-967c-3cf342181b40');
}
}
}

0 comments on commit aae0dbf

Please sign in to comment.