-
-
Notifications
You must be signed in to change notification settings - Fork 900
feat: support collect denormalization errors #5170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
features/main/validation.feature
Outdated
] | ||
} | ||
""" | ||
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: Maybe this line should be before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we check the response so its ok
@@ -419,7 +419,7 @@ protected function setAttributeValue(object $object, string $attribute, mixed $v | |||
* | |||
* @throws InvalidArgumentException | |||
*/ | |||
protected function validateType(string $attribute, Type $type, mixed $value, string $format = null): void | |||
protected function validateType(string $attribute, Type $type, mixed $value, string $format = null, array &$context): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: It's a BC break (add a default value?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't have to be a reference also
@@ -226,7 +226,6 @@ private function normalizeDefaults(array $defaults): array | |||
foreach ($rc->getConstructor()->getParameters() as $param) { | |||
$publicProperties[$param->getName()] = true; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: Please revert these changes.
/** | ||
* DummyWithCollectDenormalizationErrors. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: Can be removed.
if (!$exception instanceof NotNormalizableValueException) { | ||
continue; | ||
} | ||
$message = sprintf('The type of the "%s" attribute must be "%s", "%s" given.', $exception->getPath(), implode(', ', $exception->getExpectedTypes() ?? []), $exception->getCurrentType()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be better to use by default a message like in Symfony Validator componen: This value should be of type {{ type }}.
so it would be translated if validator and translation components are dependencies of application?
de28527
to
aaf4452
Compare
aaf4452
to
0864591
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice job!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 🙂
Related to symfony/symfony#21239 and symfony/symfony#42502.
Add property
collectDenormalizationErrors
in Operation (set tofalse
by default), setting this property totrue
will enable collecting denormalization type errors to return them as constraint violations.