angular-ui-validate
Advanced tools
Comparing version 1.2.1 to 1.2.2
/*! | ||
* angular-ui-validate | ||
* https://github.com/angular-ui/ui-validate | ||
* Version: 1.2.1 - 2015-10-23T01:56:25.746Z | ||
* Version: 1.2.2 - 2015-11-28T04:02:29.413Z | ||
* License: MIT | ||
@@ -78,3 +78,3 @@ */ | ||
} else { | ||
return expression; | ||
return !!expression; // Transform 'undefined' to false (to avoid corrupting the NgModelController and the FormController) | ||
} | ||
@@ -81,0 +81,0 @@ }; |
/*! | ||
* angular-ui-validate | ||
* https://github.com/angular-ui/ui-validate | ||
* Version: 1.2.1 - 2015-10-23T01:56:25.746Z | ||
* Version: 1.2.2 - 2015-11-28T04:02:29.413Z | ||
* License: MIT | ||
*/ | ||
!function(){"use strict";angular.module("ui.validate",[]).directive("uiValidate",["$$uiValidateApplyWatch","$$uiValidateApplyWatchCollection",function(a,i){return{restrict:"A",require:"ngModel",link:function(t,n,l,e){var u,c=t.$eval(l.uiValidate);c&&(angular.isString(c)&&(c={validator:c}),angular.forEach(c,function(a,i){u=function(n,l){var u=t.$eval(a,{$value:n,$modelValue:n,$viewValue:l,$name:e.$name});return angular.isObject(u)&&angular.isFunction(u.then)?(u.then(function(){e.$setValidity(i,!0)},function(){e.$setValidity(i,!1)}),!0):u},e.$validators[i]=u}),l.uiValidateWatch&&a(t,e,t.$eval(l.uiValidateWatch),l.uiValidateWatchObjectEquality),l.uiValidateWatchCollection&&i(t,e,t.$eval(l.uiValidateWatchCollection)))}}}]).directive("uiValidateAsync",["$$uiValidateApplyWatch","$$uiValidateApplyWatchCollection","$timeout","$q",function(a,i,t,n){return{restrict:"A",require:"ngModel",link:function(t,l,e,u){var c,r=t.$eval(e.uiValidateAsync);r&&(angular.isString(r)&&(r={validatorAsync:r}),angular.forEach(r,function(a,i){c=function(i,l){var e=t.$eval(a,{$value:i,$modelValue:i,$viewValue:l,$name:u.$name});return angular.isObject(e)&&angular.isFunction(e.then)?e:n(function(a,i){setTimeout(function(){e?a():i()},0)})},u.$asyncValidators[i]=c}),e.uiValidateWatch&&a(t,u,t.$eval(e.uiValidateWatch),e.uiValidateWatchObjectEquality),e.uiValidateWatchCollection&&i(t,u,t.$eval(e.uiValidateWatchCollection)))}}}]).service("$$uiValidateApplyWatch",function(){return function(a,i,t,n){var l=function(){i.$validate()};angular.isString(t)?a.$watch(t,l,n):angular.isArray(t)?angular.forEach(t,function(i){a.$watch(i,l,n)}):angular.isObject(t)&&angular.forEach(t,function(i){angular.isString(i)&&a.$watch(i,l,n),angular.isArray(i)&&angular.forEach(i,function(i){a.$watch(i,l,n)})})}}).service("$$uiValidateApplyWatchCollection",function(){return function(a,i,t){var n=function(){i.$validate()};angular.isString(t)?a.$watchCollection(t,n):angular.isArray(t)?angular.forEach(t,function(i){a.$watchCollection(i,n)}):angular.isObject(t)&&angular.forEach(t,function(i){angular.isString(i)&&a.$watchCollection(i,n),angular.isArray(i)&&angular.forEach(i,function(i){a.$watchCollection(i,n)})})}})}(); | ||
!function(){"use strict";angular.module("ui.validate",[]).directive("uiValidate",["$$uiValidateApplyWatch","$$uiValidateApplyWatchCollection",function(a,i){return{restrict:"A",require:"ngModel",link:function(t,n,l,e){var u,c=t.$eval(l.uiValidate);c&&(angular.isString(c)&&(c={validator:c}),angular.forEach(c,function(a,i){u=function(n,l){var u=t.$eval(a,{$value:n,$modelValue:n,$viewValue:l,$name:e.$name});return angular.isObject(u)&&angular.isFunction(u.then)?(u.then(function(){e.$setValidity(i,!0)},function(){e.$setValidity(i,!1)}),!0):!!u},e.$validators[i]=u}),l.uiValidateWatch&&a(t,e,t.$eval(l.uiValidateWatch),l.uiValidateWatchObjectEquality),l.uiValidateWatchCollection&&i(t,e,t.$eval(l.uiValidateWatchCollection)))}}}]).directive("uiValidateAsync",["$$uiValidateApplyWatch","$$uiValidateApplyWatchCollection","$timeout","$q",function(a,i,t,n){return{restrict:"A",require:"ngModel",link:function(t,l,e,u){var c,r=t.$eval(e.uiValidateAsync);r&&(angular.isString(r)&&(r={validatorAsync:r}),angular.forEach(r,function(a,i){c=function(i,l){var e=t.$eval(a,{$value:i,$modelValue:i,$viewValue:l,$name:u.$name});return angular.isObject(e)&&angular.isFunction(e.then)?e:n(function(a,i){setTimeout(function(){e?a():i()},0)})},u.$asyncValidators[i]=c}),e.uiValidateWatch&&a(t,u,t.$eval(e.uiValidateWatch),e.uiValidateWatchObjectEquality),e.uiValidateWatchCollection&&i(t,u,t.$eval(e.uiValidateWatchCollection)))}}}]).service("$$uiValidateApplyWatch",function(){return function(a,i,t,n){var l=function(){i.$validate()};angular.isString(t)?a.$watch(t,l,n):angular.isArray(t)?angular.forEach(t,function(i){a.$watch(i,l,n)}):angular.isObject(t)&&angular.forEach(t,function(i){angular.isString(i)&&a.$watch(i,l,n),angular.isArray(i)&&angular.forEach(i,function(i){a.$watch(i,l,n)})})}}).service("$$uiValidateApplyWatchCollection",function(){return function(a,i,t){var n=function(){i.$validate()};angular.isString(t)?a.$watchCollection(t,n):angular.isArray(t)?angular.forEach(t,function(i){a.$watchCollection(i,n)}):angular.isObject(t)&&angular.forEach(t,function(i){angular.isString(i)&&a.$watchCollection(i,n),angular.isArray(i)&&angular.forEach(i,function(i){a.$watchCollection(i,n)})})}})}(); |
{ | ||
"name": "angular-ui-validate", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"author": "https://github.com/angular-ui/ui-validate/graphs/contributors", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -68,3 +68,3 @@ /** | ||
} else { | ||
return expression; | ||
return !!expression; // Transform 'undefined' to false (to avoid corrupting the NgModelController and the FormController) | ||
} | ||
@@ -71,0 +71,0 @@ }; |
@@ -18,2 +18,6 @@ describe('uiValidate', function () { | ||
var undefinedValidator = function () { | ||
return undefined; | ||
}; | ||
beforeEach(module('ui.validate')); | ||
@@ -40,3 +44,3 @@ beforeEach(inject(function ($rootScope, $compile) { | ||
compileAndDigest('<input name="input" ng-model="value" ui-validate="\'validate($value)\'">', scope); | ||
expect(scope.form.input.$valid).toBeTruthy(); | ||
expect(scope.form.input.$valid).toBe(true); | ||
expect(scope.form.input.$error).toEqual({}); | ||
@@ -49,5 +53,15 @@ })); | ||
compileAndDigest('<input name="input" ng-model="value" ui-validate="\'validate($value)\'">', scope); | ||
expect(scope.form.input.$valid).toBeFalsy(); | ||
expect(scope.form.input.$valid).toBe(false); | ||
expect(scope.form.input.$error).toEqual({ validator: true }); | ||
})); | ||
it('should not corrupt the NgModelController and the FormController if the validator returns undefined', inject(function () { | ||
scope.validate = undefinedValidator; | ||
compileAndDigest('<input name="input" ng-model="value" ui-validate="\'validate($value)\'">', scope); | ||
expect(scope.form.input.$valid).toBe(false); | ||
expect(scope.form.$valid).toBe(false); | ||
expect(scope.form.input.$error).toEqual({ validator: true }); | ||
})); | ||
}); | ||
@@ -62,6 +76,6 @@ | ||
compileAndDigest('<input name="input" ng-model="value" ui-validate="\'validate($value)\'">', scope); | ||
expect(scope.form.input.$valid).toBeFalsy(); | ||
expect(scope.form.input.$valid).toBe(false); | ||
scope.$apply('value = true'); | ||
expect(scope.form.input.$valid).toBeTruthy(); | ||
expect(scope.form.input.$valid).toBe(true); | ||
})); | ||
@@ -82,3 +96,3 @@ }); | ||
var inputElm = compileAndDigest('<input name="input" ng-model="value" ui-validate="\'validate($value)\'">', scope); | ||
expect(scope.form.input.$valid).toBeFalsy(); | ||
expect(scope.form.input.$valid).toBe(false); | ||
@@ -88,3 +102,3 @@ inputElm.val('true'); | ||
expect(scope.form.input.$valid).toBeTruthy(); | ||
expect(scope.form.input.$valid).toBe(true); | ||
}); | ||
@@ -101,5 +115,5 @@ }); | ||
compileAndDigest('<input name="input" ng-model="value" ui-validate="{key1 : \'validate1($value)\', key2 : \'validate2($value)\'}">', scope); | ||
expect(scope.form.input.$valid).toBeFalsy(); | ||
expect(scope.form.input.$error.key1).toBeFalsy(); | ||
expect(scope.form.input.$error.key2).toBeTruthy(); | ||
expect(scope.form.input.$valid).toBe(false); | ||
expect(scope.form.input.$error.key1).toBeUndefined(); | ||
expect(scope.form.input.$error.key2).toBe(true); | ||
}); | ||
@@ -106,0 +120,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
47547
708
0