1.2.0 • Published 1 year ago

vue-formulario v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Vue Formulario

Form validator with mongoose-like schema validator for Vue 3.

  • 🔑 Mogoose-like schema validation
  • 💡 Validate on submit
  • ⚡️ Validate while typing
  • 🛠️ Custom formats and keywords
  • :speech_balloon: Custom error messages

Try it!

See the live demo

Install via NPM

$ npm install vue-formulario

Install via CDN

<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/vue-formulario"></script>
<script>
  const { Formulario, Validation } = VueFormulario
  const app = Vue.createApp({
    data () {
      return {
        form: {
          name: '',
          email: ''
        },
        schema: {
          name: {
            type: String,
            required: true
          },
          email: {
            type: String,
            format: 'email',
            required: [true, 'Custom error message']
          }
        }
      }
    }
  })
  app.use(Formulario)
  app.use(Validation)
  app.mount('#app')
</script>

Register as Component

import { Formulario, Validation } from 'vue-formulario'

export default {
  components: {
    Formulario,
    Validation
  }
}

Quick example

<template>
  <Formulario v-model="form" :schema="schema" @validated="submitForm" @error="errorHandler">
    <Validation for="firstName">
      <label>First name</label>
      <input v-model="form.firstName" type="text">
    </Validation>
    <Validation for="lastName">
      <label>Last name</label>
      <input v-model="form.lastName" type="text">
    </Validation>
    <Validation for="email">
      <label>Email</label>
      <input v-model="form.email" type="text">
    </Validation>
  </Formulario>
</template>

<script>
import { Formulario, Validation } from 'vue-formulario'

export default {

  name: 'App',

  components: {
    Formulario,
    Validation
  },

  data () {
    return {
      form: {
        firstName: '',
        lastName: '',
        email: ''
      },
      schema: {
        firstName: {
          type: String,
          required: true
        },
        lastName: {
          type: String
          required: [true, 'Custom error message']
        },
        email: {
          type: String,
          format: 'email'
        }
      }
    }
  }

}
</script>

License

Vue Formulario is open-sourced software licensed under the MIT license

1.2.0

1 year ago

1.1.9

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.12

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago