title: How to create a tuple prop-type checker?
body: <p>I'm trying to create a custom "tuple" prop-type for React, however, I've hit a bit of a roadblock.</p>
  
  <p>The API would look like this:</p>
  
  <pre><code>import {PropTypes} from 'react';
  
  export default class MyComponent extends React.Component {
  
      static propTypes = {
          myProp: tuple(PropTypes.number, PropTypes.string),
      };
  </code></pre>
  
  <p>This would ensure that <code>myProp</code> is a 2-element array, with the first element being a number, and the second being a string.</p>
  
  <p>Here's how far I got:</p>
  
  <pre><code>export function tuple(...arrayOfTypeCheckers) {
      return requirable(function(props, propName, componentName) {
          let value = props[propName];
          if(!Array.isArray(value)) {
              throw new Error(`Expected array for \`${propName}\` in \`${componentName}\``);
          }
          if(value.length !== arrayOfTypeCheckers.length) {
              throw new Error(`\`${propName}\` must have exactly ${arrayOfTypeCheckers.length} elements in \`${componentName}\`, got ${value.length}`);
          }
          for(let i = 0; i &lt; value.length; ++i) {
              let checker = arrayOfTypeCheckers[i];
  
              if(!__NEED_HELP_HERE__) {
                  throw new Error(`${propName}[${i}] is not of the expected type in \`${componentName}\``)
              }
          }
  
          return null;
      });
  }
  </code></pre>
  
  <p>(Implementation of <code>requirable</code> can be found <a href="https://github.com/facebook/react/issues/1715#issuecomment-168943070" rel="nofollow">here</a>)</p>
  
  <p>However, I can't figure out how to implement <code>__NEED_HELP_HERE__</code>. <code>PropTypes.string</code> is another prop-type with the signature,</p>
  
  <pre><code>function(props, propName, componentName)
  </code></pre>
  
  <p>You'll notice it takes an object full of props, plus a propName. The value is accessed as,</p>
  
  <pre><code>var propValue = props[propName];
  </code></pre>
  
  <p>Which means I can't supply my own value from the array.</p>
  
  <p>How can I call into React's <code>PropTypes.xyz</code> validators?</p>