Skip to content
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

Serializer Config #136

Merged
merged 8 commits into from
Aug 17, 2023

Conversation

adrum
Copy link
Contributor

@adrum adrum commented Jan 15, 2023

This allows for multiple serialization formats. It keeps the default while allowing other serialization types, such as decimal, integer and intl.

@ricardogobbosouza
Copy link
Member

Hi @adrum
Could you give an example use case?

@hasfoug
Copy link

hasfoug commented Mar 28, 2023

This would be cool to have since it gives flexibility over how you wanna serialize money values by default. E.g. I only need to include amounts in my response, so now in order to achieve that I have to always format them manually, while this feature allows me to set it once and money values will be serialized in my responses as I need.

@adrum
Copy link
Contributor Author

adrum commented Mar 30, 2023

@hasfoug that's exactly the use case I had. We just needed the decimal amount and not the full money object parts.

The project I used this on did not need currency included when serializing our Money values. We are already using this branch in our project months prior to the initial PR creation, so I figured I would formalize it for a PR to see if there was interest in upstreaming it.

It in theory supports providing serializer class, in case the options available do not meets someone's needs.

@Artessan
Copy link

Artessan commented Apr 2, 2023

this is useful when the model is serialized and deserialized ex: direct binding as livewire property or queue job when the model has to be passed as array and then build using new Model(array).

As the serialization generate an array for the field when the "new model" is used the cast throw an error. This could be solved with this pr or adding in each cast the check for array and validating the amount value with the type of the cast

@ricardogobbosouza
Copy link
Member

@adrum could you add tests?

@adrum
Copy link
Contributor Author

adrum commented Apr 8, 2023

@ricardogobbosouza We should be good to go with tests! Let me know if you think of anything else.

@ricardogobbosouza ricardogobbosouza self-assigned this Apr 10, 2023
@ricardogobbosouza
Copy link
Member

Thanks @adrum

@ricardogobbosouza ricardogobbosouza merged commit 5baaae7 into cknow:main Aug 17, 2023
@adrum adrum deleted the feature/serializer-config branch June 30, 2024 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants