-
I am using RHF to make a multistep form. On each step, I run I ran into an issue where a user could not submit the form (at the last step). Turns out, on an optional number field, in a non-final section, they entered "nil" into a What's the most idiomatic way to ensure either no value is passed, or the value passed is a valid number (in an
Edits: Related issues/discussions: #6980? Things I have tried/considered: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I usually recommend using the register("age", {
valueAsNumber: true,
required: true // or a validation error message string
}) This way the validation fails if |
Beta Was this translation helpful? Give feedback.
I usually recommend using the
required
validation constraint in this scenario:This way the validation fails if
NaN
is received.