mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
37 lines
826 B
Vue
37 lines
826 B
Vue
<script setup lang="ts">
|
|
import { reactive } from 'vue'
|
|
|
|
const state = reactive({ email: undefined, password: undefined })
|
|
|
|
function validate(data: Partial<typeof state>) {
|
|
const errors: Array<{ name: string, message: string }> = []
|
|
if (!data.email) errors.push({ name: 'email', message: 'Required' })
|
|
if (!data.password) errors.push({ name: 'password', message: 'Required' })
|
|
return errors
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<UForm
|
|
:validate="validate"
|
|
:state="state"
|
|
class="space-y-4"
|
|
>
|
|
<UFormField
|
|
name="email"
|
|
label="Email"
|
|
>
|
|
<UInput v-model="state.email" />
|
|
</UFormField>
|
|
<UFormField
|
|
name="password"
|
|
label="Password"
|
|
>
|
|
<UInput v-model="state.password" />
|
|
</UFormField>
|
|
<UButton type="submit">
|
|
Submit
|
|
</UButton>
|
|
</UForm>
|
|
</template>
|