title: ES6 function parameter validation
body: <p>I've read a great pattern of handling required function parameters on <a href="http://2ality.com/2014/04/required-parameters-es6.html" rel="nofollow noreferrer">2ality</a>.</p>
  
  <pre><code>function throwIfMissing() {
      throw new Error('Missing parameter');
  }
  function foo(mustBeProvided = throwIfMissing()) {
      return mustBeProvided;
  }
  </code></pre>
  
  <p>Is there any such nice and clean way to throw validation errors?</p>
  
  <pre><code>function throwIfInvalid(value) {
      const max = 10;
      const min = 5;
  
      if(value &lt; min || value &gt; max){
          throw new Error(`Value must be between ${min} ${max}`);
      }
  
      return value;
  }
  
  function foo(mustBeValid = throwIfInvalid()) {
      return mustBeValid;
  }
  </code></pre>
  
  <p>Of course the <code>throwIfInvalid()</code> function does not work as expected. My question is if there is any trick to make it work.?</p>