Prop cross-validation
What problem does this feature solve?
This issue I had frequently in vue 2 as well but never really questioned it. Is there a reason why the prop validator doesn't have access to the other props? If so I could not find any related discussion.
This would be very helpful if I would like to validate a prop one way if another prop is present, and another way if it isn't.
As far as I can tell the props can be passed to the validateProp from here
There is currently a workaround using watchers, but in my opinion that isn't as clean as this would be.
I would be happy to PR this if wanted.
What does the proposed API look like?
prop: {
type: Array,
required: true,
validator: (value, props) => {
return props.someBooleanFlag
? ... validate one way
: ... validate another way
}
},
It wasn't possible in Vue 2 (https://github.com/vuejs/vue/issues/6787) but I think this would be really helpful
I think this can be closed now since https://github.com/vuejs/core/pull/3258 has been merged and released as part of v3.4