Skip to content

[Serializer] Add ScalarNormalizer to allow custom values for boolean #58473

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

Open
wants to merge 1 commit into
base: 6.4
Choose a base branch
from

Conversation

Hanmac
Copy link
Contributor

@Hanmac Hanmac commented Oct 6, 2024

Q A
Branch? 7.2
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #58305 , Fix #58056
License MIT

i want to fix #58429 with this MR too, but that might need some thinking first

It still does work when the Normalizer is used with Serializer (like it normally would?),
but currently it crashes some Testcases I probably need to fix first. (that's why this is still a draft)

Even without the new ScalarNormalizer, it should still return return the expected result

@carsonbot

This comment was marked as outdated.

@Hanmac Hanmac marked this pull request as ready for review October 6, 2024 19:43
@Hanmac Hanmac requested a review from dunglas as a code owner October 6, 2024 19:43
@carsonbot carsonbot added this to the 6.4 milestone Oct 6, 2024
@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "6.4" but it seems your PR description refers to branch "7.2 for features / 5.4, 6.4, and 7.1 for bug fixes".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@carsonbot
Copy link

It looks like you unchecked the "Allow edits from maintainer" box. That is fine, but please note that if you have multiple commits, you'll need to squash your commits into one before this can be merged. Or, you can check the "Allow edits from maintainers" box and the maintainer can squash for you.

Cheers!

Carsonbot

@Hanmac
Copy link
Contributor Author

Hanmac commented Oct 6, 2024

"Allow edits from maintainer" doesn't work because that is a Group Repository

@OskarStark OskarStark changed the title Add ScalarNormalizer to allow custom values for boolean Add ScalarNormalizer to allow custom values for boolean Oct 8, 2024
@carsonbot carsonbot changed the title Add ScalarNormalizer to allow custom values for boolean [Serializer] Add ScalarNormalizer to allow custom values for boolean Oct 8, 2024
@andreybotanic
Copy link

Your fix is very specific. Why ScalarNormalizer allows only booleans? You probably should create BooleanNormalizer instead. And it also mast supports denormalization, so you have to add appropriate methods and fix demormalization method in AbstractObjectNormalizer

@Hanmac
Copy link
Contributor Author

Hanmac commented Oct 9, 2024

@andreybotanic because this is only the start, for #58429 I wanted to add something to format numeric/float/int too,
but I first need to think what the best way would be. Probably "sprintf" Format Strings?

Yeah, denormalization might need to be done too. My use-case was for normalizing into stuff that can be denormalized too. (like "true/false" for boolean.)

I will try to update the denormalize way soon. (for example, "yes/no" for boolean)

@Hanmac
Copy link
Contributor Author

Hanmac commented Jan 29, 2025

@nicolas-grekas similar to #59501 can you look into this MR?

I need to find a way to normalize boolean into "true" and "false" instead of "1" and "0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants