Skip to content

Commit

Permalink
Default touch to true
Browse files Browse the repository at this point in the history
  • Loading branch information
rzane committed Feb 25, 2022
1 parent 68bc74f commit b5434b5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/useSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ type SubmitFn<T> = (values: T) => void | Promise<any>;
export function useSubmit<Value, Result>(
form: Form<Value, Result>,
fn: SubmitFn<Result>,
opts: ValidateOptions = { touch: true }
opts: ValidateOptions = {}
): Submit {
const isMounted = useMounted();
const { touch = true } = opts;

return useEventCallback((event?: FormEvent<HTMLFormElement>) => {
if (event) {
Expand All @@ -37,7 +38,7 @@ export function useSubmit<Value, Result>(

form.setSubmitting(true);

return toPromise(() => form.validate(opts))
return toPromise(() => form.validate({ touch }))
.then(result => {
if (!result.valid) return;

Expand Down

0 comments on commit b5434b5

Please sign in to comment.