resolvers icon indicating copy to clipboard operation
resolvers copied to clipboard

[effect-ts] Expected string, actual undefined

Open fredericrous opened this issue 1 year ago • 1 comments

Describe the bug using effect-ts resolver, when I click submit, I get the error "Expected string, actual undefined" however I expect my custom error to show (which is "name required")

To Reproduce Steps to reproduce the behavior:

  • use the example provided on the readme, something like
const schema = S.Struct({
  name: S.String.pipe(S.nonEmpty({ message: () => 'name required' })),
})
  • click inside the input text field

    do not write anything in the input field

  • click submit button

    an error shows up: Expected string, actual undefined

Expected behavior "'name required" should have been shown, but we got "Expected string, actual undefined"

Desktop (please complete the following information): not relevant but here it is

  • OS: macOS 14.5
  • Browser: chrome
  • Version: 126.0.6478.127

Additional context

"@effect/schema": "^0.68.26",
"@hookform/resolvers": "^3.9.0",

fredericrous avatar Jul 24 '24 09:07 fredericrous

a workaround is to set the default value to an empty string

fredericrous avatar Jul 24 '24 09:07 fredericrous