pablo-abc / felte

An extensible form library for Svelte, Solid and React
https://felte.dev
MIT License
1.02k stars 44 forks source link

Errors not clearing properly when adding/removing fields array items and validating with zod #267

Open marleau opened 1 year ago

marleau commented 1 year ago

Describe the bug

If an invalid array item exists, the error messages keep accumulating for each invalid array item when adding/removing an array item and validating with zod.

Which package/s are you using?

felte (Svelte), @felte/validator-zod

Environment

To reproduce

  1. Open the reproduction
  2. Click button add invalid item
  3. See one error message for the invalid item
  4. Click button add invalid item
  5. See two duplicate error messages for the first invalid item and one error for the second invalid item.
  6. Click remove button
  7. See three duplicate error messages for the first invalid item

Small reproduction example

https://svelte.dev/repl/024824e323544a8fa08b6abc4b09f33c?version=4.2.0

Screenshots

felte-zod-field-array-item-error-issue

Additional context

No response

marleau commented 1 year ago

I did a little more testing. I see this issue for any invalid field. It doesn't have to be a field array.

Here is a an updated reproduction: https://svelte.dev/repl/d63036e3a4a345748909a6c082cd809f?version=4.2.0