title: How to manually call custom PropType validators in React v16
body: <p>I have a use case where I need to write a custom React <code>PropType</code> validator. Within that checker I want to do two things: 1) validate that the prop names inside the object, which are dynamically generated, are all md5 hashes, and 2) validate the "shape" of the object connected to each prop.</p>
  
  <p>Question #1 I have figured out; #2 is eluding me a bit. Here's some code to illustrate: </p>
  
  <p>Say I have an object like this:</p>
  
  <pre><code>{
    key1: {
      byHash: {
        '&lt;some md5 hash&gt;': { ... }
      }
    },
    key2: {
      byHash: {
        '&lt;some md5 ash&gt;': { ... }
      }
    }
  }
  </code></pre>
  
  <p>When checking this object I want to make sure that the keys are indeed md5 hashes, and then I want to ensure the correctness of the keys and their values in each of the objects assigned to <code>key1</code> and <code>key2</code>. Let's say, in addition, I've created a validator function like so:</p>
  
  <pre><code>const validObjShape = PropTypes.shape({
    someString: PropTypes.string.isRequired,
    someBoolean: PropTypes.bool
  });
  </code></pre>
  
  <p>Then I write my custom validator function:</p>
  
  <pre><code>const validCustomProp  = (props, propName, componentName) =&gt; {
    const obj = props[propName];
  
    if (!isObject(obj)) {
      return new Error(
        //eslint-disable-next-line
        'Invalid prop `' + propName + '`of type `' + typeof obj + '` supplied to ' +
        '`' + componentName + '`, expected an object.'
      );
    }
  
    if (isEmpty(obj)) {
      return null;
    }
  
    forEach(obj, (v, k) =&gt; {
      const isMD5 = (/[a-fA-F0-9]{32}/).test(k);
  
      if (!isMD5) {
        throw new Error(
          //eslint-disable-next-line
          'Invalid dynamic key on `' + propName + '`. All keys ' +
          'on this object should be md5 hashes, but we found `' + k + '` instead.'
        );
      }
    });
  
    // Here I want to somehow validate each object on `obj`. Something like:
    // forEach(obj, (v, k) =&gt; { 
    //   const err = validObjShape(props[propName], k, componentName);
    //   if (err) {
    //     // throw some err...
    //   }
    // }
  
    return null;
  };
  </code></pre>
  
  <p>My question -- as noted in-line above -- can I use the <code>validObjShape</code> that I created above to validate the shape of the objects nested within <code>obj</code>. I think that this calling of a validator fn directly will be disallowed in v16 of React (see <a href="https://facebook.github.io/react/warnings/dont-call-proptypes.html" rel="nofollow noreferrer">this post</a>). So how can this now be achieved?</p>