mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-29 11:20:36 +01:00
fix(Form): return false when silent validation fails (#1371)
This commit is contained in:
@@ -109,11 +109,14 @@ export default defineComponent({
|
|||||||
errors.value = await getErrors()
|
errors.value = await getErrors()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!opts.silent && errors.value.length > 0) {
|
if (errors.value.length > 0) {
|
||||||
|
if (opts.silent) return false
|
||||||
|
|
||||||
throw new FormException(
|
throw new FormException(
|
||||||
`Form validation failed: ${JSON.stringify(errors.value, null, 2)}`
|
`Form validation failed: ${JSON.stringify(errors.value, null, 2)}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return props.state
|
return props.state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
3
src/runtime/types/form.d.ts
vendored
3
src/runtime/types/form.d.ts
vendored
@@ -10,7 +10,8 @@ export interface FormErrorWithId extends FormError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Form<T> {
|
export interface Form<T> {
|
||||||
validate(path?: string, opts?: { silent?: boolean }): Promise<T>
|
validate(path?: string, opts?: { silent?: true }): Promise<T | false>;
|
||||||
|
validate(path?: string, opts?: { silent?: false }): Promise<T>;
|
||||||
clear(path?: string): void
|
clear(path?: string): void
|
||||||
errors: Ref<FormError[]>
|
errors: Ref<FormError[]>
|
||||||
setErrors(errs: FormError[], path?: string): void
|
setErrors(errs: FormError[], path?: string): void
|
||||||
|
|||||||
Reference in New Issue
Block a user