Skip to content

Commit 0474c8a

Browse files
committed
Fixed customizable initial validation.
1 parent 3f9ff21 commit 0474c8a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/directive.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
require: 'ngModel',
120120
scope: {
121121
model: '=ngModel',
122+
initialValidity: '=initialValidity',
122123
validCallback: '&',
123124
invalidCallback: '&'
124125
},
@@ -153,9 +154,17 @@
153154
element.after('<span></span>');
154155

155156
/**
156-
* Set Validity to false when Initial
157+
* Set initial validity to false if no boolean value is transmitted
157158
*/
158-
ctrl.$setValidity(ctrl.$name, false);
159+
if (typeof scope.initialValidity !== 'boolean') {
160+
scope.initialValidity = false;
161+
}
162+
163+
/**
164+
* Set custom initial validity
165+
* Usage: <input initial-validity="true" ... >
166+
*/
167+
ctrl.$setValidity(ctrl.$name, scope.initialValidity);
159168

160169
/**
161170
* Reset the validation for specific form

0 commit comments

Comments
 (0)