title: Custom form validation directive to compare two fields
body: <p>I'm an angular newbie, and I'm stumbling over something in how angular's form validation directives work.</p>
  
  <p>I know that I can fairly easily add directives to <em>individual fields</em>, but I'm trying to add a validation which will <em>compare two form fields</em> (both of which are elements of a model). </p>
  
  <p>Here's a form skeleton:</p>
  
  <pre><code>&lt;form name="edit_form" &gt;
    &lt;input name="min" type="number" ng-model="field.min"/&gt;
    &lt;input name="max" type="number" ng-model="field.max"/&gt;
  &lt;/form&gt;
  
  &lt;div class="error" ng-show="edit_form.min.$dirty || edit_form.max.$dirty"&gt;
    &lt;small class="error" ng-show="(what goes here?)"&gt;
      Min cannot exceed max
    &lt;/small&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>In short, I want to write a directive and use it to show/hide this <code>small.error</code> if <code>min</code> and <code>max</code> both have values but <code>min &gt; max</code>. How can I access both fields inside one directive? Is a directive the right tool for this job?</p>