I'm new to Vue.js and I'm trying to do form validation on a dynamically created form. The input fields are determined via the json object it gets from an ajax call. I've looked around and found a lot of form validation libraries, but all of them seem to need a static data property in the vue instance in order for the validation portion to work. e.g.
...
data() {
return {
name: '',
age: '',
...
}
}
...
but because the fields in my forms depend on the json object, I can't hardcode these values in data. One method I thought of trying was loop through the json object, grab a unique key value (like the field name), pair it with an empty value, and then store that object in a data variable that I pass into the data field in the vue instance. But that's also dependent on each input field having a unique name (what if there are multiple fields that are named "First Name" that are all required?).
Is this the correct approach? Or is there some fundamental concept that I'm missing? Please let me know if I need to provide some more information about this! Thanks.
My set up: main.js (instantiates the vue instance and calls upon App.js, which is a component) --> App.js contains the data field, as well as calls upon all the other components (e.g. input field, radio button, checkbox, etc), depending on which ones are in the json object