diff --git a/src/runtime/components/forms/Form.vue b/src/runtime/components/forms/Form.vue index b5e8e0b1..27fd0baa 100644 --- a/src/runtime/components/forms/Form.vue +++ b/src/runtime/components/forms/Form.vue @@ -109,11 +109,14 @@ export default defineComponent({ errors.value = await getErrors() } - if (!opts.silent && errors.value.length > 0) { + if (errors.value.length > 0) { + if (opts.silent) return false + throw new FormException( `Form validation failed: ${JSON.stringify(errors.value, null, 2)}` ) } + return props.state } diff --git a/src/runtime/types/form.d.ts b/src/runtime/types/form.d.ts index 70ece906..93f62897 100644 --- a/src/runtime/types/form.d.ts +++ b/src/runtime/types/form.d.ts @@ -10,7 +10,8 @@ export interface FormErrorWithId extends FormError { } export interface Form { - validate(path?: string, opts?: { silent?: boolean }): Promise + validate(path?: string, opts?: { silent?: true }): Promise; + validate(path?: string, opts?: { silent?: false }): Promise; clear(path?: string): void errors: Ref setErrors(errs: FormError[], path?: string): void