You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems there is no way to tell vee-validate to treat our class instance as a whole and not treat each property separately.
Imagine this:
<CountrySelectv-model="country" />
constschema=object({country: mixed((inp): inp is Country=>inpinstanceofCountry).required().label('Country'),});constform=useForm({validationSchema: toTypedSchema(schema)});const[country]=form.defineField('country');
country ref is supposed to be of type Country | undefined, but it is of type PartialDeepObject<Country> | undefined.
the input, returns "country" as a whole or no country at all.
This is a bit of a limitation sadly because there is no way for vee-validate to know if the country itself is the field or if it is a container for a bunch of fields.
Think about it like this, a phone object with name, flag properties can be expressed in two ways with fields:
A select input that picks the country object from its options. The field emits the { name, flag } object as a value. This looks like your case here.
Or a couple of nested fields country.name and country.flag and while this may not make sense in this example it does for other types of objects.
There is no way for vee-validate to know where the nesting stops and where the field is actually, all it knows that it has a schema and that schema leafs can be fields. So that's why it uses the PartialDeep type here.
Unless I work on a completely different schema validation system that takes this into account, I don't think I can do much here.
@logaretm Yup already treats the country as a whole when you use mixed validator. there is no problem in the schema validation part I suppose.
It is vee-validate that adds partial deep to everything.
What happened?
It seems there is no way to tell vee-validate to treat our class instance as a whole and not treat each property separately.
Imagine this:
country
ref is supposed to be of typeCountry | undefined
, but it is of typePartialDeepObject<Country> | undefined
.the input, returns "country" as a whole or no country at all.
Reproduction steps
No response
Version
Vue.js 3.x and vee-validate 4.x
What browsers are you seeing the problem on?
Relevant log output
No response
Demo link
No need
Code of Conduct
The text was updated successfully, but these errors were encountered: