Skip to content
This repository was archived by the owner on Aug 15, 2021. It is now read-only.

Commit 90d0c06

Browse files
committed
Fixed a problem with ng-model-options updateOn blur/default with debounce not validating - a bit of a tricky problem!
1 parent a86904c commit 90d0c06

7 files changed

+26
-16
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-auto-validate",
3-
"version": "1.19.2",
3+
"version": "1.19.3",
44
"description": "An automatic validation module for AngularJS which gets rid of excess html in favour of dynamic element modification to notify the user of validation errors",
55
"main": "dist/jcs-auto-validate.js",
66
"keywords": [

dist/changelog.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v1.19.3 30/11/2015
2+
Fixed a problem with ng-model-options updateOn blur/default with debounce not validating - a bit of a tricky problem!
3+
14
v1.19.2 30/11/2015
25
Added ability for the library to delay showing validation hints on an element while async validators are firing.
36
This functionality is enabled by default - to disbale it change the 'waitForAsyncValidators' option in the defaultFormValidationOptions

dist/jcs-auto-validate.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* angular-auto-validate - v1.19.2 - 2015-11-30
2+
* angular-auto-validate - v1.19.3 - 2015-11-30
33
* https://github.com/jonsamwell/angular-auto-validate
44
* Copyright (c) 2015 Jon Samwell (http://www.jonsamwell.com)
55
*/
@@ -1394,7 +1394,10 @@ angular.module('jcs-autoValidate').config(['$provide',
13941394
if (attrs.formnovalidate === undefined &&
13951395
(frmCtrl !== undefined && frmCtrl !== null && frmCtrl.autoValidateFormOptions &&
13961396
frmCtrl.autoValidateFormOptions.disabled === false)) {
1397-
if (!supportsNgModelOptions || ngModelOptions === undefined || ngModelOptions.updateOn === undefined || ngModelOptions.updateOn === '') {
1397+
// if the version of angular supports ng-model-options let angular handle the element.on bit
1398+
// fixes issue with async validators
1399+
if (supportsNgModelOptions ||
1400+
(!supportsNgModelOptions || ngModelOptions === undefined || ngModelOptions.updateOn === undefined || ngModelOptions.updateOn === '')) {
13981401
ngModelCtrl.$setValidity = function (validationErrorKey, isValid) {
13991402
setValidity.call(ngModelCtrl, validationErrorKey, isValid);
14001403
setValidationState();

dist/jcs-auto-validate.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-auto-validate",
3-
"version": "1.19.2",
3+
"version": "1.19.3",
44
"description": "An automatic validation module for AngularJS which gets rid of excess html in favour of dynamic element modification to notify the user of validation errors",
55
"main": "angular-auto-validate.min.js",
66
"scripts": {

src/config/ngModelDecorator.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ angular.module('jcs-autoValidate').config(['$provide',
3434
if (attrs.formnovalidate === undefined &&
3535
(frmCtrl !== undefined && frmCtrl !== null && frmCtrl.autoValidateFormOptions &&
3636
frmCtrl.autoValidateFormOptions.disabled === false)) {
37-
if (!supportsNgModelOptions || ngModelOptions === undefined || ngModelOptions.updateOn === undefined || ngModelOptions.updateOn === '') {
37+
// if the version of angular supports ng-model-options let angular handle the element.on bit
38+
// fixes issue with async validators
39+
if (supportsNgModelOptions ||
40+
(!supportsNgModelOptions || ngModelOptions === undefined || ngModelOptions.updateOn === undefined || ngModelOptions.updateOn === '')) {
3841
ngModelCtrl.$setValidity = function (validationErrorKey, isValid) {
3942
setValidity.call(ngModelCtrl, validationErrorKey, isValid);
4043
setValidationState();

tests/testPageAsyncValidator.html

+10-9
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,22 @@
2020
</span>
2121
<input type="text" name="email" class="form-control"
2222
ng-model="user.email"
23+
ng-model-options="{ updateOn: 'default', debounce: 400 }"
2324
placeholder="Enter email address"
2425
ng-required="true"
2526
unique-email-checker/>
2627

2728
</div>
2829
</div>
29-
<div class="form-group">
30-
<label class="control-label">Name</label>
31-
<input type="text" name="name" class="form-control"
32-
ng-model="user.name"
33-
placeholder="Enter your name"
34-
ng-required="true"
35-
ng-minlength="3"/>
30+
<!--<div class="form-group">-->
31+
<!--<label class="control-label">Name</label>-->
32+
<!--<input type="text" name="name" class="form-control"-->
33+
<!--ng-model="user.name"-->
34+
<!--placeholder="Enter your name"-->
35+
<!--ng-required="true"-->
36+
<!--ng-minlength="3"/>-->
3637

37-
</div>
38+
<!--</div>-->
3839

3940
<button type="submit" class="btn btn-default">Submit</button>
4041
<button type="reset" class="btn btn-default">Reset</button>
@@ -90,7 +91,7 @@
9091
ctrl.$asyncValidators.uniqueEmailChecker = function(modelValue, viewValue) {
9192
var defer = $q.defer();
9293
$timeout(function() {
93-
defer.resolve(viewValue);
94+
defer.reject(viewValue);
9495
}, 2000);
9596

9697
return defer.promise;

0 commit comments

Comments
 (0)