question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: Is there any possible to read other props in a specific validator function?

See original GitHub issue

As above, I want to validate a props data propA in the validator function and I want to read the props data propB so that I can judge whether they are valid together.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:17
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

9reactions
fnlctrlcommented, Aug 23, 2016

@JounQin As @LinusBorg has said, the feature for prop validation depending on other props is too complex, error-prone (needs correct prop initialization order), not commonly needed, and cannot solve the problem of interdependent validation (propA requires propB, propB require propA). On the other hand, it’s already easy enough to be implemented with computed properties. So in my opinion this feature shouldn’t be included in vue since it’s too user-specific.

Therefore my recommendations remain to be a). use computed properties. b). use a mixin to check inside hooks.

1reaction
JounQincommented, Aug 23, 2016

@fnlctrl your solution is just like validating them together on the created() hook, but I think we should do the validation in a proper place rather than mixing it in our business logic.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to validate React props using PropTypes - LogRocket Blog
Learn how to validate props with React PropTypes, React's internal mechanism for adding type checking to component props.
Read more >
How to apply validation on Props in ReactJS ? - GeeksforGeeks
React JS has an inbuilt feature for validating props data type to make sure that values passed through props are valid. React components...
Read more >
React eslint error missing in props validation - Stack Overflow
It can not correctly detect what props were mentioned in propTypes if you have annotated named objects via destructuring anywhere in the class....
Read more >
Typechecking With PropTypes - React
For some applications, you can use JavaScript extensions like Flow or TypeScript to typecheck your whole application. But even if you don't use...
Read more >
How To Customize React Components with Props
Props are the arguments you pass to a function or class, but since your components are transformed into HTML-like objects with JSX, you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found