Effect-TS / effect

An ecosystem of tools to build robust applications in TypeScript.
https://effect.website
MIT License
6.82k stars 215 forks source link

From Discord: Utility for Overriding Decoder ParseOptions at Schema Level #3027

Closed effect-bot closed 2 months ago

effect-bot commented 2 months ago

Summary

Summary:

  1. Initial Request: The user shared a TypeScript utility they created, which overrides the ParseOptions for a decoder at the schema level in the @effect/schema library. They asked for a review and inquired if this functionality is planned to be included in @effect/schema directly.

  2. Code Overview: The provided utility function, parseOptions, takes overridden options and a schema, and returns a new schema with custom decode and encode functions that merge the provided options with the existing ones.

  3. User's Opinion: The user believes that setting ParseOptions at the schema level is more useful than setting them globally.

  4. Expert Feedback: Another user, gcanti, suggested that this use case might be better handled by an annotation that the parser can read and use as an override.

Key Takeaways:

Discord thread

https://discord.com/channels/795981131316985866/1253095927405609080

gcanti commented 2 months ago

https://github.com/Effect-TS/effect/pull/3028