Replies: 1 comment
-
Commenting here for posterity This issue took me down a rabbit hole. The good type. The initial main concern, and the reason I posted here, was that I didn't understand how
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a rather large form and not all inputs are required (in fact, only two).
Using server actions I want to validate in the client before submitting the form.
In
useForm
I set the resolver toajvResolver
and in the JSON Schema I list the required fieldsrequired: ['first_name', 'acct_number']
.The
handleSubmission
function uses thetrigger
method to manually trigger the form validation (from this thread)Because the form has many optional input fields, when the
trigger
is executed the input data of the optional fields is set to''
(empty string) and validation errors for those optional fields are returned.I was expecting, if a user does not input text in the optional fields, the optional field data is not an empty string but
null
or the input field is not present in the form data. It appears my thinking here is incorrect, right?How to go about setting the optional fields to
null
or removing them from the form data upon submission using thetrigger
method? Is this possible? Is there another way to tackle this problem? Is this an issue with the resolver?Beta Was this translation helpful? Give feedback.
All reactions