I am currently working on a Vue.js component that requires a prop named idFieldType
The goal is to only allow this prop to accept values of type Number or String
To achieve this, I implemented the following code:
idFieldType: {
Type: Function,
default: function() {
return Number;
},
validator: function(value) {
if(value == String || value == Number) {
return true;
}
return false;
}
}
I also experimented with changing the type to Object.
My main concern is how can I create a prop that restricts input to specific types?