title: Custom validators with AngularJs
body: <p>I'm writing my own custom AngularJs validators which look like this:</p>
  
  <pre><code>.directive('float', function ($log) {
      return {
          restrict: 'A',
          require: 'ngModel',
          scope: {float: '='},
          link: function ($scope, ele, attrs, ctrl) {
              var settings = $scope.float || {};
  
              ctrl.$validators.float = function(value) {
                  var valid = isTheInputValidFunction( settings );
                  ctrl.$setValidity('float', valid);
                  return valid;
              };
          }
      };
  });
  </code></pre>
  
  <p>I'm using the validators like so:</p>
  
  <pre><code>&lt;input type="text"ng-model="someVar" name="preis" float="{precision: 5, scale: 2}"&gt;
  </code></pre>
  
  <p>However, as soon as I attach multiple validators, I get the following error:</p>
  
  <blockquote>
    <p>Multiple directives [...] asking for new/isolated scope</p>
  </blockquote>
  
  <p>This is, because all my validators get a settings-object which has to be passed into the scope <code>scope: {float: '='}</code>.</p>
  
  <p>I know that I can use <code>var settings = JSON.parse(attrs.float);</code> in the directives, but it doesn't look right.</p>
  
  <p>So my question is:</p>
  
  <p><strong>How do you correctly implement custom validators in AngularJs?</strong></p>