title: Angular 2, custom validation messages with parameters
body: <p>I'm just starting with JS/Typescript and Angular 2 and I'm struggling with the following.</p>
  
  <pre><code>export function MinImageDimensionsValidator(minWidth: number, minHeight: number): ValidatorFn {
  
  return (control: AbstractControl): { [key: string]: any } =&gt; {
  
          // it's an image control where a user uploads an image.
          // the whole image related code has been removed for better readability. 
          //Just assume that 'actualWidth' holds the actual width of the image
  
          if(actualWidth &lt; minWidth) {
             return { valid: false };
          }
  
          return null;
  };
  </code></pre>
  
  <p>}</p>
  
  <p>this is just a very basic example of a validator factory.</p>
  
  <p>All the examples I found just wrote the validation messages/errors directly in the template (I'm using template forms)</p>
  
  <p>Is it possible to "tie" the validation messages to the validator itself and use parameters with it?</p>
  
  <p>like:</p>
  
  <pre><code>'Min width has to be 100. you supplied ' + actualWidth
  </code></pre>
  
  <p>this would be returned from the validator itself.</p>
  
  <p>or is there another way (apart from storing everything in variables somewhere) ?</p>