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

Add an API solution to use this package as generic validation as well. #260

Closed
rgraffbrd opened this issue Feb 26, 2019 · 1 comment
Closed

Comments

@rgraffbrd
Copy link
Contributor

The problem: When using this package to define an object shape for something like a view containing a form, you essentially need to define your validation twice, once for your props and once for your form validation. After that you need the same definition on your server, somehow, most likely. Using multiple type definition mechanisms and defining what is essentially the same structure multiple times is a shame and seems like a real waste.

The proposed solution: This package is already a great basis for generic validation. You could simply expose a method of some sort that would allow passing an object and running the prop-types validation on it. At that point it could even be used on the server.

As a bonus: Add a means of supplying custom errors/error messages.

I am aware that you are not supposed to call the prop types functions so that "it is safe to strip their implementations to optimize the bundle size". However, it would be a huge benefit to provide a means of keeping specific declarations of them intact.

Overall, you have such a nice package for defining these types of semantics here, I'd just like to see it reach it's full potential. :)

@ljharb
Copy link
Collaborator

ljharb commented Feb 26, 2019

Closing as a duplicate of #133. Also a duplicate of #34.

@ljharb ljharb closed this as completed Feb 26, 2019
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

2 participants