airjp73/rvf

[Bug]: superRefine() is not called when all fields use zfd.text()

stefan-girlich opened this issue · 2 comments

Which packages are impacted?

  • remix-validated-form
  • @remix-validated-form/with-zod
  • @remix-validated-form/with-yup
  • zod-form-data

What version of these packages are you using?

"zod": "^3.22.4",
"zod-form-data": "^2.0.2"

Please provide a link to a minimal reproduction of the issue.

https://codesandbox.io/p/sandbox/zod-form-data-superrefine-98n8pc?file=%2Fsrc%2Findex.js%3A26%2C1

Steps to Reproduce the Bug or Issue

  1. Open sandbox link
  2. Open in-editor dev console
  3. Refresh in-editor preview
    => superRefine() is not called (call is not logged to console)

Expected behavior

superRefine() is called even when input is invalid according to zod rules

Screenshots or Videos

No response

Platform

  • OS: MacOS
  • Node v21.6.2

Additional context

superRefine() is not called when all field validators are wrapped in zfd.text()

Hi! Thanks for the reproduction.

In the sandbox you provided, the superRefine isn't being called because your test data doesn't pass the other validations. superRefine will only be called if the schema is valid in the first place.

const invalidInput = {
  items: [
    {
      id: 0,
      name: "",
    },
  ],
};

This data is invalid because id isn't a string, and name doesn't meet the minimum length of 1. If you change the data to fulfill that criteria, then superRefine will be called. The same is true for all three versions of the validations you provided in the comments.

Thanks for the quick clarification!