Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[serializer] Extra attributes may throw exception when denormalize #19948

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

Closed
juliendidier opened this issue Sep 16, 2016 · 2 comments
Closed
Labels
Feature Good first issue Ideal for your first contribution! (some Symfony experience may be required) Serializer

Comments

@juliendidier
Copy link
Contributor

During the denormalization of an object, the AbstractObjectNormalizer do not throw exception when an attribute is not in allowed. As a result I can denormalize an array to an object with not mapped attributes.

I'm currently designing an API.
Users are not allowed to send extra attributes that are not mapped to my class.
I want to throw an exception on this case.

Is it possible to implement this feature inside the Serializer component ?

@dunglas
Copy link
Member

dunglas commented Sep 17, 2016

It is not currently implemented but it should be trivial to add to the current normalizer.
It would be a nice improvement but it should he optional and disabled by default.

@dunglas dunglas added Serializer Good first issue Ideal for your first contribution! (some Symfony experience may be required) Feature labels Sep 17, 2016
dunglas added a commit that referenced this issue Dec 5, 2016
… used during an object denor… (juliendidier)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[Serializer] Throw exception when extra attributes are used during an object denor…

| Q | A |
| --- | --- |
| Branch? | "master" |
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | #19948 |
| License | MIT |
| Doc PR | [#6975](symfony/symfony-docs#6975) |

I will update the doc if you're ok with this PR.

Commits
-------

565a984 throw exception when extra attributes are used during an object denormalization
@Simperfit
Copy link
Contributor

@dunglas this can be closed ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Good first issue Ideal for your first contribution! (some Symfony experience may be required) Serializer
Projects
None yet
Development

No branches or pull requests

3 participants