Dependent props rules
What problem does this feature solve?
There are two attributes, width and height, which are not required. But if you pass width, you must pass height. In other words, the required options of height need to change with whether width is required
What does the proposed API look like?
let heightRequired = false;
const props = {
width: {
type: String,
required: heightRequired,
},
height: {
type: String,
validator: (value) => {
if (value) {
// Height is required if it is a valid value
heightRequired = true;
} else {
heightRequired = false;
}
return value;
},
},
};
You could use one prop and have it accept ob object like { height: number, width: number }
Or validate the combo in a computed property.