Currently, I am passing a set of props called "propSet" to a child component. These props are computed and detect an 'edit mode' boolean that changes accordingly.
The "propSet" defines the following form input props: color, filled, dense, outlined, readonly, required, and rules.
All the props work fine, except for "rules". Whenever a child component uses the 'editMode == true' configuration of "propSet," I receive the following error message in the console:
[Vue warn]: Invalid prop: type check failed for prop "rules". Expected Array, got Object
I have tried various solutions, including:
Adding type validation to the Child Component for the rules array
props: ['propSet'] //original
props: { propSet: Array } //updated
Using Object.entries() to convert the object to an array
var rulesSet = Object.entries(this.rules)
Adjusting the configuration of rules
-
//original rules: { required: (v) => !!v || "This field is required", autoComplete: (v) => !!(v && v.length) || "This field is required", },
-
//updated rules: [{ required: (v) => !!v || "This field is required"}, autoComplete: (v) => !!(v && v.length) || "This field is required", }],
-
Despite reading the documentation for Props multiple times and exploring related sources such as the Vuetify API, I haven't found a solution yet. I've also checked several Stack Overflow questions regarding Vue.js, props, and components without success.
I suspect there might be something obvious that I'm overlooking. For simplicity's sake, here is a codepen with a different set of props that showcases the issue: