Closed kiankji closed 5 years ago
Please provide a JSFiddle.
As VFG doesn’t claim to work with Vee Validate, and provides its own validation... I can’t consider this a bug report.
Thanks for your reply Here's the jsfiddle https://jsfiddle.net/ha0xyc27/1/
This is a compatibility issue. I'm unfamiliar with VeeValidate itself, but looking at your example JSFiddle there is clearly a compatibility issue.
I'm not sure why you would need or want to use VeeValidate on top of VueFormGenerator though.
VFG has it's own Validation rules built-in, and you can easily integrate something like [validate.js](https://validatejs.org/)
into VFG for more enhanced validation, as well as extend the validation rules in VFG.
Example for integrating validate.js
with VFG,
let ValidateJsObj = {};
window.ValidateJs = new Proxy(ValidateJsObj, {
get(target, name) {
return (value, schema, model) => {
let constraint = {};
let rules = {
[name]: _.get(schema.rules, name, true)
};
constraint[schema.model] = rules;
return validate.async(
model,
constraint,
{
cleanAttributes: false,
format: "flat"
}
).then((errors) => {
return [];
}).catch((err) => {
console.error('ValidateJs:catch', err);
return err;
});
};
}
});
example schema:
{
"type": "input",
"inputType": "number",
"label": "Price",
"model": "price",
"min": 0,
"rules": {
"numericality": {
"greaterThanOrEqualTo": 0
}
},
"validator": [ValidateJs.numericality]
}
The solution:
The injected props are: "$validator", "errors" and "fields". You can customize the names of the last 2 using the configuration
Vue.use(VeeValidate, { errorBagName: 'somethingelse', fieldsBagName: 'somethingelse' });
Thanks @logaretm https://github.com/baianat/vee-validate/issues/1809
I'm submitting a ...
What is the current behavior?
By including the vee-validation package the fields of vue-form-generator disappear without showing any errors.
The fields of vue-form-generator should still be visible
two different forms one with vee-validation and one with vue-form-generator
Thanks for your help