Skip to content

Joi

Install the necessary packages via package manager:

bash
npm i @vue-formify/joi joi

Import the helper function to convert joi schema for vue-formify specific schema:

vue
<script lang="ts" setup>
import Joi from 'joi';
import { schemaFromJoi } from '@vue-formify/joi';
import { FormifyForm, FormifyInput } from 'vue-formify';

const schemajoi = schemaFromJoi(
  Joi.object({
    first_name: Joi.string().required(),
    last_name: Joi.string().required(),
  })
);

const sendForm = (data) => {
	console.log(data);
};

</script>
<template>
	<FormifyForm :validation-schema="schemajoi" @submit="sendForm">
        <FormifyInput name="first_name" label="First name" />
        <FormifyInput name="last_name" label="Last name" />
    <button>Submit</button>
  </FormifyForm>
</template>