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

Poor support for validating Map/Set/Iterable #288

Closed
conartist6 opened this issue Aug 29, 2019 · 2 comments
Closed

Poor support for validating Map/Set/Iterable #288

conartist6 opened this issue Aug 29, 2019 · 2 comments

Comments

@conartist6
Copy link
Contributor

The prop-types code makes an assumption at the core API level that it will always be possible to traverse the entire props object using only the array access operator, as (value[keyName]).

This assumption breaks when attempting to validate iterables, particularly Sets and Maps.

I have a working implementation of mapOf and setOf validators which I will put up in a PR as soon as I have corporate approval. The problem is that you're validating, say that a Set contains only items of PropTypes.number, there's no way to refer to an item in the set using the array access operator.

Modifying what prop-types does internally is not a major issue, but changing to a pattern that simply gives the value to validate would be a breaking change for the public API of custom validators.

Is there a willingness to follow through on such a breaking change?

@conartist6
Copy link
Contributor Author

For the moment I'm doing a hack: I'm passing the validators [value], 0 for a Set item. It's probably Good Enough for now, but it the error messages don't read quite right.

@conartist6
Copy link
Contributor Author

Oops, duplicated #190

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

1 participant