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

Add support for distinguishing explicit and implicit null in ArgBuilders #929

Merged
merged 8 commits into from
Jun 17, 2021

Conversation

stephendavidmarsh
Copy link
Contributor

This PR adds support for distinguishing between explicit null, where a null was sent to an input, from implicit null, where no value was provided for an input field. It uses an approach inspired by zio-json's JsonDecoder, adding a new buildMissing method to ArgBuilder that by default calls build with NullValue. The new method is called when a field is missing. This change should be backwards compatible, with no change in behavior for existing ArgBuilder instances.

New ArgBuilder instances can override the buildMissing method to customize their behavior when a value is missing and provide different behavior from when null is supplied.

@@ -39,6 +43,30 @@ object Scala2SpecificSpec extends DefaultRunnableSpec {
"""{"events":[{"organizationId":7,"title":"Frida Kahlo exhibition"}],"painters":[{"name":"Claude Monet","movement":"Impressionism"}]}"""
)
)
},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the test is same for Scala 2 and Scala 3, you can simply add it in the scala folder, no need to duplicate it. These files are just for Scala2 or Scala3 specific features (like Scala 3 enums).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason I though it had to be there for it to run for each version - I'll move the test.

Copy link
Owner

@ghostdogpr ghostdogpr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@ghostdogpr ghostdogpr merged commit 6ac0b94 into ghostdogpr:master Jun 17, 2021
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.

2 participants