-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Description
What problem does this feature solve?
Right now (2.4.4), props can be validated based on their value, but are unable to take other props into consideration. With access to a props object, we could do more complex validation.
For example, imagine a component with a foo
and bar
prop, where at least one of these props must be defined. Currently, this logic would have to be placed in the component's lifecycle hooks or render function. I would like the ability to keep it within the validator
functions, as I think it's a more appropriate place for the logic.
What does the proposed API look like?
export default {
props: {
foo: {
validator: (foo, props) => foo || props.bar
},
bar: {
validator: (bar, props) => bar || props.foo
}
}
}
achiandet, kkempster94, axle07, rcf117, wanganjun and 5 more