iway1 / react-ts-form

https://react-ts-form.com
MIT License
2.01k stars 35 forks source link

issue: missing required error after the input has been changed #60

Closed haivuw closed 1 year ago

haivuw commented 1 year ago

Version Number

1.1.3

Codesandbox/Expo snack

https://codesandbox.io/s/react-typescript-forked-j8cy2u?file=/src/App.tsx

Steps to reproduce

  1. Type something in the input then clear it.
  2. Hit submit button. -> onSubmit called even though the input is empty.

Expected behaviour

Shows *Required error.

Relevant log output

No response

haivuw commented 1 year ago

I think we need to check for empty string also: https://github.com/iway1/react-ts-form/blob/291f32f3e677547a47ec30e9572378147ff20868/src/FieldContext.tsx#L107

haivuw commented 1 year ago

It seems I need to change my schema instead. https://github.com/colinhacks/zod/discussions/1950