Skip to content
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

Prop validation, mix of array and object hash syntax #1798

Closed
fergaldoyle opened this issue Nov 12, 2015 · 4 comments
Closed

Prop validation, mix of array and object hash syntax #1798

fergaldoyle opened this issue Nov 12, 2015 · 4 comments

Comments

@fergaldoyle
Copy link
Contributor

After searching I couldn't find if this was already suggested and discounted, but at the moment when we can specify component props with a simple array of strings or complex object hash.

I think I might be useful if we could mix the two:

props: [
    'propA',
    'propB',
    {
        name: 'propC',
        type: Number,
        default: 100
    },
    'propD'
]

I often find I have props in an array of strings, and at a later stage need to add a prop which has validation. Meaning I have to concert the array of strings to a hash.

@shuaibird
Copy link

Is this feature supported in v2?
I've tried it and got the warning: props must be strings when using array syntax.

@thomasaull
Copy link

I'm getting the same error, when putting the props-example from the test (8ed14c8#diff-2092e089df2ae66b53f34b1d728f3acc) in my component:

props: [ 'b', { name: 'c', type: Number }, { name: 'd', required: true } ],

@vibrantBits
Copy link

Is there an accepted practice/answer to this issue?

@penance316
Copy link

A bit late but was this ever sorted? I just noticed I am having the same issues as mentioned. Mixing prop types as shown in the tests is throwing an error.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants