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

feat(effect-validator): use array formatting for errors #718

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shokiw
Copy link

@shokiw shokiw commented Aug 27, 2024

@effect/schema uses TreeFormatter as the default way of formatting errors. (more here)

The result is hard to read in an http 400 response (although it is really nice in a terminal):

{
  "success": false,
  "error": {
    "_id": "ParseError",
    "message": "{ readonly name: string; readonly password: string; readonly email: a string matching the pattern ^(?!\\.)(?!.*\\.\\.)([A-Z0-9_+-.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9-]*\\.)+[A-Z]{2,}$ }\n└─ [\"password\"]\n   └─ is missing"
  }
}

With the ArrayFormatter it us much better:

{
  "success": false,
  "error": [
    {
      "_tag": "Missing",
      "path": [
        "password"
      ],
      "message": "is missing"
    }
  ]
}

What are your thoughts about this ?

Copy link

changeset-bot bot commented Aug 27, 2024

🦋 Changeset detected

Latest commit: 0df3772

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hono/effect-validator Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@yusukebe
Copy link
Member

@gunta Can you review this?

@shokiw
Copy link
Author

shokiw commented Sep 26, 2024

@yusukebe It seems like @gunta is not very active lately, can someone else review this ? Maybe @tim-smart or @mikearnaldi from the Effect team.

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