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

Export toForest from the Decoder module #590

Open
camsjams opened this issue May 14, 2021 · 4 comments
Open

Export toForest from the Decoder module #590

camsjams opened this issue May 14, 2021 · 4 comments

Comments

@camsjams
Copy link

🚀 Feature request

Current Behavior

Decoder works great! Decoder.draw is helpful but not useful when we need HTML form validation.

Desired Behavior

It would be a nice utility to expose Decoder.toForest for some extra hands-on control of error message manipulation.

Suggested Solution

Adjust the exports:

typescript
const toForest = (e: DecodeError): ReadonlyArray<Tree<string>> => {

To be:

typescript
export const toForest = (e: DecodeError): ReadonlyArray<Tree<string>> => {

Who does this impact? Who is this for?

This should not impact anyone AFAIK, since it just an additional exported member. This would make io-ts for html form validation messages much easier as we can utilize the toForest helper to do most of the lifting.

Describe alternatives you've considered

The current alternative that works for our system is to just copy->paste toForest and its related functions into our codebase.

Additional context

n/a

Your environment

Software Version(s)
io-ts 2.2.16 (2.2+)
fp-ts 2.10.5
TypeScript 4.1.3
@gcanti
Copy link
Owner

gcanti commented May 14, 2021

@camsjams I wouldn't recommend using the Decoder.ts module in production, it's still experimental and I'm working on a new version (branch poc for a sneak peek)

@steida
Copy link

steida commented May 14, 2021

@gcanti It would be great if all errors would not be mandatory an opaque string, so we could use exhaustive check without additional wrappers or hacks.

@steida
Copy link

steida commented May 14, 2021

@gcanti Do you plan big changes? I just started using experimental API. I'm OK with refactoring.

@gcanti
Copy link
Owner

gcanti commented May 15, 2021

@steida for the error model? yes. I'll write a summary of my findings in #453 as soon as possible

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 a pull request may close this issue.

3 participants