Fix/add dot notation types to data object
Because lodashes get and set are used and the errors in the response for nested fields are based on dot notation, the selectors for these fields can also be in dot notation. This pull request adds support for that notation to the Data interface.
@anned20, I'm not sure what this PR does. Can you please elaborate on what you are trying to achieve with it?
@timacdonald, when using nested fields, you need to use the dot-notation: parent.child. This PR adds TypeScript support for those keys so that they are strictly typed.
@anned20, appreciate the work you have done here. I'm not sure we want to support this right now until I see some more demand for the feature.
As a side note, if we return to this, I anticipate there would be issues with arrays where the index of the array is determined at runtime.
Please reconsider merging this pr or building a feature similar to this one. any nested fields do not have any type support.
Something like this
interface Product {
id: number;
name: string;
short_code: string;
}
const productForm = useForm<{
name: string;
product: Product | null;
}>('post', 'admin/products', {
name: '',
product: null,
});
// in template
<input v-model="productForm.product.short_code" />
// in script
productForm.validate('product.short_code') // does not work
// Argument of type '"product.short_code"' is not assignable to parameter of type '"product" | "name" | NamedInputEvent | ValidationConfig | undefined'