Skip to content

Commit 0bc2c6b

Browse files
committed
Empty and pristine fields are no succesful
Even if they validate (i.e are not required)
1 parent 44ce14e commit 0bc2c6b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/directives/schema-validate.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ angular.module('schemaForm').directive('schemaValidate',function(){
5858
});
5959

6060
//This works since we now we're inside a decorator and that this is the decorators scope.
61+
//If $pristine and empty don't show success (even if it's valid)
6162
scope.hasSuccess = function(){
62-
return scope.ngModel.$valid && !scope.ngModel.$pristine;
63+
return ngModel.$valid && (!ngModel.$pristine || !ngModel.$isEmpty(ngModel.$modelValue));
6364
};
64-
65+
6566
scope.hasError = function(){
66-
return scope.ngModel.$invalid && !scope.ngModel.$pristine;
67+
return ngModel.$invalid && !ngModel.$pristine;
6768
};
6869

6970
scope.schemaError = function() {

0 commit comments

Comments
 (0)