npm.io
7.0.1 • Published 3 weeks ago

vue-types

Licence
MIT
Version
7.0.1
Deps
0
Size
212 kB
Vulns
0
Weekly
0
Stars
583

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

MIT

Copyright (c) 2016 - present Marco Solazzi

Keywords