mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-27 18:30:35 +01:00
fix(Form): fix wrong type of validate (#496)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
committed by
Benjamin Canac
parent
8b19b1880e
commit
3d6839da97
@@ -248,7 +248,7 @@ const schema = z.object({
|
|||||||
password: z.string().min(8, 'Must be at least 8 characters')
|
password: z.string().min(8, 'Must be at least 8 characters')
|
||||||
})
|
})
|
||||||
|
|
||||||
const state: Partial<Schema> = ref({
|
const state = ref<Partial<Schema>>({
|
||||||
email: undefined,
|
email: undefined,
|
||||||
password: undefined
|
password: undefined
|
||||||
})
|
})
|
||||||
@@ -259,7 +259,7 @@ type Schema = z.output<typeof schema>
|
|||||||
const form = ref<Form<Schema>>()
|
const form = ref<Form<Schema>>()
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
const data: Schema = await form.value!.validate()
|
const data = await form.value!.validate()
|
||||||
// Do something with data
|
// Do something with data
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
2
src/runtime/types/form.d.ts
vendored
2
src/runtime/types/form.d.ts
vendored
@@ -4,7 +4,7 @@ export interface FormError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Form<T> {
|
export interface Form<T> {
|
||||||
async validate(): T
|
validate(): Promise<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FormEvent {
|
export interface FormEvent {
|
||||||
|
|||||||
Reference in New Issue
Block a user