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

Separate Invalid Enum Names to Default & Null to Default #2422

Open
Laxystem opened this issue Aug 26, 2023 · 1 comment
Open

Separate Invalid Enum Names to Default & Null to Default #2422

Laxystem opened this issue Aug 26, 2023 · 1 comment
Labels

Comments

@Laxystem
Copy link

What is your use-case and why do you need this feature?

I am working on an API, using ktor - and I've noticed the coerceInputValues config option.

On one hand, it allows us to make providing null equal to not providing anything at all (together with the explicitNulls option) in our API. To us, providing null means "no change than default", making it a valid input.

On the other hand, it turns invalid enum entries to the default - which can cause annoying, hard to fix bugs on the user's side.

Describe the solution you'd like

Separate it to two, different, config options.

@sandwwraith
Copy link
Member

We had similar concerns while developing this feature, but it turns out that this is an unpopular use case. I can recommend you omitting values instead of sending nulls to keep defaults. It will also help with schema evolution — e.g., if you make property nullable, you won't suddenly start seeing nulls. Also, you would be able to differentiate new enum values from incorrect ones.

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

No branches or pull requests

2 participants