{"size": 1819, "ext": "js", "max_stars_repo_path": "app/js/directives/form.js", "max_stars_repo_name": "dongrenfei/digitallibrary", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/js/directives/form.js", "max_issues_repo_name": "dongrenfei/digitallibrary", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/js/directives/form.js", "max_forks_repo_name": "dongrenfei/digitallibrary", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.8196721311, "max_line_length": 193, "alphanum_fraction": 0.5002748763}
var directApp = angular.module('directApp', []);
var validateEmail = /^\w{1,22}(@cn.ibm.com)$/;
var validatePwd = /(?=^\S{6,}$)(?!(^[a-zA-Z\`\~\!\@\#\$\%\^\&\*\;\:\'\"\,\<\.\>\-\_\=\+\(\)\[\]\{\}\?\/\\\|]*$))(?!(^[0-9\`\~\!\@\#\$\%\^\&\*\;\:\'\"\,\<\.\>\-\_\=\+\(\)\[\]\{\}\?\/\\\|]*$))/ ;
var validatePhone = /^[0-9]{11}$/;

directApp.directive('customEmailFormat', function() {
  return {
    require: 'ngModel',
    link: function(scope, element, attrs, ctrl) {
      scope.$watch(attrs.ngModel, function() {
        var viewValue = scope.user.intrID;
        if (viewValue != undefined) {
          if (validateEmail.test(viewValue)) {
            ctrl.$setValidity('format', true);
          } else {
            ctrl.$setValidity('format', false);
          };
        } else {
          ctrl.$setValidity('format', true);
        };
      });
    }
  }
});

directApp.directive('customPwdFormat', function() {
  return {
    require: 'ngModel',
    link: function(scope, element, attrs, ctrl) {
      scope.$watch(attrs.ngModel, function() {
        var viewValue = scope.user.pwd;
        if (validatePwd.test(viewValue)) {
          ctrl.$setValidity('format', true);
        } else {
          ctrl.$setValidity('format', false);
        };
      });
    }
  }
});

directApp.directive('customPhoneNumFormat', function() {
  return {
    require: 'ngModel',
    link: function(scope, element, attrs, ctrl) {
      scope.$watch(attrs.ngModel, function() {
        var viewValue = scope.user.phoneNum;
        if (viewValue != undefined) {
          if (validatePhone.test(viewValue)) {
            ctrl.$setValidity('format', true);
          } else {
            ctrl.$setValidity('format', false);
          };
        } else {
          ctrl.$setValidity('format', true);
        };
      });
    }
  }
});
