From fd5d9e5d3f5b4418ab44702881411c2eaee1db90 Mon Sep 17 00:00:00 2001 From: Micah Engle-Eshleman Date: Wed, 8 Nov 2023 12:52:40 -0800 Subject: [PATCH] Stop double-pruning Form values are already pruned pre-validation --- README.md | 5 ++--- tests-e2e/mock-form/form.tsx | 8 +++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 79207ac..c4bf573 100644 --- a/README.md +++ b/README.md @@ -75,9 +75,8 @@ export function Form() { name: "guests", }); - const onSubmit = () => { - const validVisibleFields = pruneHiddenFields(conditions, getValues); - // Do something with pruned submission... + const onSubmit = (data: FormSchema) => { + // Do something with pruned & validated form submission data... }; return ( diff --git a/tests-e2e/mock-form/form.tsx b/tests-e2e/mock-form/form.tsx index d110491..aea1e68 100644 --- a/tests-e2e/mock-form/form.tsx +++ b/tests-e2e/mock-form/form.tsx @@ -35,11 +35,9 @@ export function Form() { reset, } = formMethods; - const onSubmit = () => { - console.log( - "Successfully submitted", - pruneHiddenFields(conditions, formMethods.getValues) as FormSchema - ); + const onSubmit = (data: BlankFormSchema) => { + // At this point, data has passed validation + console.log("Successfully submitted", data as FormSchema); reset(getDefaultValues()); };