title: ReactJs : how to check Proptypes with function and shape?
body: <p>I have an array with this shape : </p>
  
  <pre class="lang-js prettyprint-override"><code>dataSource: PropTypes.arrayOf(
          PropTypes.shape({
            share: PropTypes.number,
            visibleInLegend: PropTypes.bool,
            order: PropTypes.number,
            color: PropTypes.string
          })
  </code></pre>
  
  <p>Now, I want to limit the lenght to be only 2. I replaced the last proptype with a function like this :
  </p>
  
  <pre><code>dataSource: function(props, propName, componentName) {
      let arrayPropLength = props[propName].length;
      if (arrayPropLength !== 2) {
        return new Error(
          `Invalid array length ${arrayPropLength} (expected 2 for prop ${propName} supplied to ${componentName}. Validation failed.`
        );
      }
    }
  </code></pre>
  
  <p>The two checks work fine, however this will test only the length of array and I want to combine both of them into a function ? to be something like this :
  </p>
  
  <pre><code>dataSource: function(props, propName, componentName) {
  props[propName].PropTypes.shape({
                share: PropTypes.number,
                visibleInLegend: PropTypes.bool,
                order: PropTypes.number,
                color: PropTypes.string
              })
          let arrayPropLength = props[propName].length;
          if (arrayPropLength !== 2) {
            return new Error(
              `Invalid array length ${arrayPropLength} (expected 2 for prop ${propName} supplied to ${componentName}. Validation failed.`
            );
          }
        }
  </code></pre>