title: AngularJS & Typescript - Add a customised $validators
body: <p>I've created the following dummy directive with typescript : </p>
  
  <pre><code> export class Room implements ng.IDirective{
      public restrict = 'A';
      public require = 'ngModel';
  
      public static DirectoryName = "room";
  
      public link = (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, ctrl : IRoomValidation) =&gt; {
        ctrl.$validators.room = function(modelValue, viewValue) {
          var ROOM_REGEXP = /^\w+$/;
          if (ctrl.$isEmpty(modelValue)) {
            // consider empty models to be valid
            return true;
          }
  
          if (ROOM_REGEXP.test(viewValue)) {
            // it is valid
            return true;
          }
  
          // it is invalid
          return false;
        };
      }
  
      public static factory(): ng.IDirectiveFactory {
        var directive = () =&gt; new Room();
        return directive;
      }
    }
  
  interface IRoomValidation extends ng.INgModelController {
      $validators : {
        room(modelValue : string, viewValue : string);
      }
    }
  </code></pre>
  
  <p>The directive gets used at the following location:</p>
  
  <pre><code> &lt;form id="form" novalidate&gt;
                    &lt;label for="creation-name"&gt;Name:&lt;/label&gt;
                    &lt;input type="text" name="name" class="form-control" id="creation-name" ng-model="lobby.currentItem.name" room&gt;
                    &lt;span ng-show="form.name.$error.room"&gt;Only alphanumeric characters are accepted as input!&lt;/span&gt;
                  &lt;/form&gt;
  </code></pre>
  
  <p>The link function in the directive gets called and evaluates as I would expect but unfortunately the error message doesn't get displayed.</p>
  
  <p><a href="https://i.stack.imgur.com/Yl5ou.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yl5ou.png" alt="enter image description here"></a></p>
  
  <p>Is there any kind of way how I can troubleshoot this problem? With the tools I know, I am very limited.</p>