Skip to content

Commit

Permalink
validateForm method now returns form status.
Browse files Browse the repository at this point in the history
  • Loading branch information
webblocksapp committed Apr 16, 2023
1 parent 05568c2 commit 8a84abc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/lib/package.json
@@ -1,7 +1,7 @@
{
"name": "solid-form-handler",
"description": "A SolidJS library for simplifying form validations.",
"version": "1.2.0-alpha.4",
"version": "1.2.0-alpha.5",
"license": "MIT",
"type": "module",
"keywords": [
Expand Down
14 changes: 10 additions & 4 deletions packages/lib/src/hooks/useFormHandler/index.ts
Expand Up @@ -607,13 +607,19 @@ export const useFormHandler = <T = any>(validationSchema: ValidationSchema<T>, o
setFormIsValidating(true);
await validateField(
ROOT_KEY,
{ force: true, omitTriggers: true, throwException: true, ...options },
{ force: true, omitTriggers: true, throwException: true, silentValidation: options?.silentValidation },
{ ..._, recursive: true }
);
setFormIsValidating(false);
return { isFormInvalid: false };
} catch (error) {
throw new FormErrorsException(error as ErrorMap);
} finally {
setFormIsValidating(false);

if (options?.throwException === false) {
return { isFormInvalid: true };
}

throw new FormErrorsException(error as ErrorMap);
}
};

Expand Down Expand Up @@ -1081,7 +1087,7 @@ export const useFormHandler = <T = any>(validationSchema: ValidationSchema<T>, o
) => Promise<void>,
touchField,
validateField: validateField as (path?: string, options?: ValidateFieldOptions) => Promise<void>,
validateForm,
validateForm: validateForm as (options?: ValidateOptions) => Promise<{ isFormInvalid: boolean }>,
_: {
addFieldsetState,
buildFieldState,
Expand Down

0 comments on commit 8a84abc

Please sign in to comment.