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

[valibot] Validation errors reported by ‘checkItems’ are not displayed properly #707

Open
Thanaen opened this issue Jul 29, 2024 · 0 comments

Comments

@Thanaen
Copy link

Thanaen commented Jul 29, 2024

Describe the bug
Validation errors reported by ‘checkItems’ should be displayed in the same way as other errors

To Reproduce
Steps to reproduce the behavior:

  1. Focus the first input
  2. Insert "t"
  3. Submit (to trigger a length error)
  4. Update the input value to "value"
  5. Add another input using the "Add input" button
  6. Insert "value" in the newly added input
  7. Submit

Codesandbox link (Required)
https://stackblitz.com/edit/vitejs-vite-yj5g5r?file=src%2FApp.tsx

Expected behavior
Validation errors reported by ‘checkItems’ should be displayed in the same way as other errors

Form schema:

const FormSchema = v.object({
  test: v.pipe(
    v.array(
      v.object({
        value: v.pipe(v.string(), v.minLength(4)),
      })
    ),
    v.checkItems(
      (item, index, values) =>
        values.map((v) => v.value).indexOf(item.value) === index,
      'Duplicate items'
    )
  ),
});

Error displayed properly:
image

Error not displayed properly:
image

Additional context

"dependencies": {
    "@hookform/resolvers": "^3.9.0",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "react-hook-form": "^7.52.1",
    "valibot": "^0.36.0"
  }
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

No branches or pull requests

1 participant