facebook/react — pull request #2717 by pletcher (2014-12-16 00:31:34+00:00)
Title: Adds a dependsOn type checker

The dependsOn type checker takes a name or an array of names of other props that the current prop expects to be present, as well as an optional type checker for the current prop. This allows property declarations along the lines of:

```
React.createClass({
propTypes: {
one: React.PropTypes.dependsOn('two', React.PropTypes.string),
two: React.PropTypes.string
}
});
```

where the presence of `one` is only validated if `two` is present.

While using `dependsOn` with `isRequired` might be a little weird, it does work. `dependsOn` doesn't change existing APIs.

--

Note: I'm not sure if this is something that the community is interested in, but I thought I would offer it up for discussion. We've been finding ourselves writing custom `dependsOn`-like validations in our components, and after a moment's consideration, we thought that it might be nice to put it out there for other people to use if desired.