yunohost-portal/components/BaseForm.vue
2023-07-25 19:20:06 +02:00

25 lines
531 B
Vue

<script setup lang="ts">
import { useForm } from 'vee-validate'
import { toTypedSchema } from '@vee-validate/yup'
import * as yup from 'yup'
const props = defineProps<{
schema: yup.ObjectShape
}>()
const emit = defineEmits(['submit'])
const { handleSubmit } = useForm({
validationSchema: toTypedSchema(yup.object(props.schema)),
})
const onSubmit = handleSubmit((values) => {
emit('submit', values)
})
</script>
<template>
<form novalidate @submit.prevent="onSubmit">
<slot name="default" />
</form>
</template>