zio / zio-schema

Compositional, type-safe schema definitions, which enable auto-derivation of codecs and migrations.
https://zio.dev/zio-schema
Apache License 2.0
135 stars 151 forks source link

Check default value existence for transient fields in derive macro #654

Closed 987Nabil closed 1 week ago

987Nabil commented 5 months ago

Since schemas only consider constructor arguments, every field that is marked as transient without having a default value is basically a bug, since codecs can't create these values.

The idea would be, to check in the derive macros if there is a default value (either via the schema for the field or the fieldDefaultValue annotation) and throw an error if there is none. This would make is user error compile time.

The only use case I can think of that this might not be nice for are write only schemas that did not need a default value before, but would need one after this change. But I would consider this a good trade off.

jdegoes commented 1 month ago

/bounty $75

algora-pbc[bot] commented 1 month ago

💎 $75 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #654 with your implementation plan
  2. Submit work: Create a pull request including /claim #654 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to zio/zio-schema!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🔴 @manishwin Jun 21, 2024, 6:39:56 AM WIP
🟢 @987Nabil #708
algora-pbc[bot] commented 3 weeks ago

@manishwin: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

algora-pbc[bot] commented 2 weeks ago

💡 @987Nabil submitted a pull request that claims the bounty. You can visit your bounty board to reward.

algora-pbc[bot] commented 2 weeks ago

The bounty is up for grabs! Everyone is welcome to /attempt #654 🙌

algora-pbc[bot] commented 1 week ago

🎉🎈 @987Nabil has been awarded $75! 🎈🎊