Skip to content

Commit

Permalink
Fixed customizable initial validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurhenning committed Jul 18, 2014
1 parent 3f9ff21 commit 0474c8a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
require: 'ngModel',
scope: {
model: '=ngModel',
initialValidity: '=initialValidity',
validCallback: '&',
invalidCallback: '&'
},
Expand Down Expand Up @@ -153,9 +154,17 @@
element.after('<span></span>');

/**
* Set Validity to false when Initial
* Set initial validity to false if no boolean value is transmitted
*/
ctrl.$setValidity(ctrl.$name, false);
if (typeof scope.initialValidity !== 'boolean') {
scope.initialValidity = false;
}

/**
* Set custom initial validity
* Usage: <input initial-validity="true" ... >
*/
ctrl.$setValidity(ctrl.$name, scope.initialValidity);

/**
* Reset the validation for specific form
Expand Down

0 comments on commit 0474c8a

Please sign in to comment.