You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
User (jessekelly): Encountered an issue where Schema.annotations({ message: Effect }) wasn't picking up on the context in TypeScript.
Code Example: Provided a code snippet where the message was defaulting to "default" instead of using the context.
Solution Provided:
gcanti: Suggested using formatError explicitly instead of formatIssueSync to make the context visible.
Updated Code: Provided an updated code snippet that resolved the issue.
Further Discussion:
michaelarnaldi: Asked if message could see the context when evaluated in a fiber.
dilame_bowzee: Suggested that Schema.filter should accept a function returning an Effect for better i18n support.
jessekelly: Agreed and mentioned using transformOrFail for custom filters.
gcanti: Explained that filter cannot return an Effect because it models an AST.Refinement, but suggested creating a filterEffect function that builds upon transformOrFail.
Implementation of filterEffect:
gcanti: Provided a code example for filterEffect that builds upon transformOrFail.
Discussion on Extending Refinement:
michaelarnaldi: Asked if it was possible to extend Refinement to support effects.
gcanti: Mentioned that extending Refinement would have significant implications and that currently, "Effect" is compartmentalized in AST.Transformations.
PR Suggestion:
dilame_bowzee: Offered to create a PR with the filterEffect function.
gcanti: Responded that they have some spare time and can work on it.
Key Takeaways
Explicit Use of formatError: When dealing with schema annotations that need to pick up context, use formatError explicitly.
Custom Filters with Effects: While filter cannot return an Effect, a custom filterEffect function can be created using transformOrFail.
Impact of Extending Refinement: Extending Refinement to support effects would have significant implications and needs careful evaluation.
Community Collaboration: The discussion shows active community collaboration, with members offering to create PRs and contribute code examples.
Summary
Summary of the Discussion
Initial Issue:
Schema.annotations({ message: Effect })
wasn't picking up on the context in TypeScript.Solution Provided:
formatError
explicitly instead offormatIssueSync
to make the context visible.Further Discussion:
message
could see the context when evaluated in a fiber.Schema.filter
should accept a function returning anEffect
for better i18n support.transformOrFail
for custom filters.filter
cannot return anEffect
because it models anAST.Refinement
, but suggested creating afilterEffect
function that builds upontransformOrFail
.Implementation of
filterEffect
:filterEffect
that builds upontransformOrFail
.Discussion on Extending Refinement:
Refinement
to support effects.Refinement
would have significant implications and that currently, "Effect" is compartmentalized inAST.Transformation
s.PR Suggestion:
filterEffect
function.Key Takeaways
formatError
: When dealing with schema annotations that need to pick up context, useformatError
explicitly.filter
cannot return anEffect
, a customfilterEffect
function can be created usingtransformOrFail
.Refinement
to support effects would have significant implications and needs careful evaluation.Discord thread
https://discord.com/channels/795981131316985866/1243877438795288586
The text was updated successfully, but these errors were encountered: