app.directive('pwdconfirm', function(){
   return {
       require: 'ngModel',
       link: function(scope, elm, attrs, ctrl){
           ctrl.$validators.pwdconfirm = function(modelValue, viewValue) {
               return scope.user && scope.user.password == viewValue;
           }
       }
   }
});

app.directive('unconfirm', function(){
    return {
        require: 'ngModel',
        link: function(scope, elm, attrs, ctrl){
            ctrl.$validators.unconfirm = function(modelValue, viewValue) {
                if(viewValue == ""){
                    return true;
                }
                return (/^[a-zA-Z\d]\w{0,23}[a-zA-Z\d]{0,1}$/.test(viewValue));
            }
        }
    }
});