fix(Form): fix wrong type of validate (#496)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Paul Grau
2023-08-04 19:22:42 +09:00
committed by Benjamin Canac
parent 8b19b1880e
commit 3d6839da97
2 changed files with 3 additions and 3 deletions

View File

@@ -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>

View File

@@ -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 {