-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Multi-type prop validation is not consistent #3879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
getType func seems not to deal with multi-type props, it just returns the first type I will try to make a pr |
I'm not sure to understand the issue. Were you expecting the value to be cast as a Boolean? Although you said it was either a String or a Boolean?. Why would using the order to specify what the prop should be cast to be non-consistent? |
Not consistent: Because the behaviour differs between |
What do you mean by magic? Do you refer when there's no value? |
I referred to the piece of code mentioned in "Observations" above. |
I'll share the rest of the team. |
Vue.js version
2.0.1
Reproduction Link
https://jsfiddle.net/alexman/f7sb0rd3/9/
Steps to reproduce
Create a component with a prop of type
[String, Boolean]
and instantiate it with a boolean value or shorthand prop notation. (<my-component my-prop></my-component>
)What is Expected?
Booleans are accepted and passed to the validator as a boolean value.
What is actually happening?
You'll see that it will not validate booleans / shorthand prop notation.
Defining it reversed,
[Boolean, String]
, does seem to work as expected except for not being able to pass false as a value.Observations
I noticed
validateProp()
does the following "magic", which doesn't seem to take the option of an array of types into account?The text was updated successfully, but these errors were encountered: