Skip to content

Commit

Permalink
Stop double-pruning
Browse files Browse the repository at this point in the history
Form values are already pruned pre-validation
  • Loading branch information
micahjon committed Nov 8, 2023
1 parent f287857 commit fd5d9e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
8 changes: 3 additions & 5 deletions tests-e2e/mock-form/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
};

Expand Down

0 comments on commit fd5d9e5

Please sign in to comment.