Skip to content

kvoon3/zod-arco-rules

Repository files navigation

zod-arco-rules

npm version npm downloads bundle JSDocs License

arco design vue zod validation

Install

npm i zod-arco-rules

Usage

<script setup lang="ts">
import * as z from 'zod'
import { zodArcoRules } from 'zod-arco-rules'

const { rules, handleSubmit } = zodArcoRules(z.object({
  name: z.string().nonempty(),
  post: z.string().min(2).max(30),
  isRead: z.boolean(),
}))

const onSubmit = handleSubmit((values) => {
  // Handle the validated values here
})
</script>

<template>
  <a-form :model="form" :rules @submit="onSubmit">
    <!-- ... -->
  </a-form>
</template>

Todos

  • Valibot support
  • a-form validation status
  • Auto form

License

MIT License © 2024-PRESENT Kevin Kwong