Skip to content

Instantly share code, notes, and snippets.

@uno-de-piera
Created May 24, 2018 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uno-de-piera/13e2ea20a4d891292adc8dce783c3436 to your computer and use it in GitHub Desktop.
Save uno-de-piera/13e2ea20a4d891292adc8dce783c3436 to your computer and use it in GitHub Desktop.
<template>
<div class="validation-component">
<h1>Extender validaciones con Vuejs 2 + VeeValidate</h1>
<form novalidate @submit.prevent="validateAndSubmit" id="custom-form">
<input type="password" v-model="password" name="password" v-validate="'required|min:8|verify_password'" />
<p>{{ password }}</p>
<span v-if="errors.has('password')">{{ errors.first('password') }}</span>
</form>
</div>
</template>
<script>
export default {
name: 'ValidationComponent',
data () {
return {
password: ''
}
},
methods: {
validateAndSubmit() {
this.$validator.validateAll().then((result) => {
if (result) {
console.log("success...");
} else {
console.log(this.errors);
console.log("error...");
}
});
},
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment