vue-types
Prop type definitions for Vue.js.
vue-types is a collection of configurable prop validators for Vue.js inspired by React's prop-types. It offers a compact and fluent interface to define your component props.
Starting from v6, vue-types is only compatible with Vue 3. For older versions, see the v2~v5 documentation.
Try it now! or learn more at the official documentation site.
Installation
npm install vue-types --save
Usage
import { defineComponent } from 'vue'
import { number, string, integer } from 'vue-types'
export default defineComponent({
props: {
id: number().def(10),
name: string().isRequired,
age: integer().def(0),
nationality: string(),
},
})
It works with <script setup> too:
defineProps({
id: number().def(10),
name: string().isRequired,
age: integer().def(0),
nationality: string(),
})
License
Copyright (c) 2016 - present Marco Solazzi