I have a vue file validations.vue of validations.js.
validations.vue
<script>
import VueFormGenerator from "vue-form-generator";
Vue.use(VueFormGenerator);
VueFormGenerator.validators.postcode = function(value, field, model) {
let re = /^[1-9][0-9]{3} ?[A-Za-z]{2}$/;
if (!re.test(value)) {
return ["Ongeldige postcode"];
} else {
return []
}
};
</script>
Postcode check:
import VueFormGenerator from "vue-form-generator";
Vue.use(VueFormGenerator);
export default {
data() {
return {
model: {
postcode: "",
huisnummer: ''
},
schema: {
fields: [{
type: "input",
inputType: "text",
model: "postcode",
placeholder: "Postcode",
label: "Postcode",
validator: VueFormGenerator.validators.postcode, <---------------
},{
How can i make it accessible in all vue files?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire