Skip to content
This repository was archived by the owner on Jul 1, 2020. It is now read-only.

Commit 2da6923

Browse files
committed
fix #160 validate on empty validation-service
1 parent e7ff68c commit 2da6923

7 files changed

+25
-24
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-validation-ghiscoding",
3-
"version": "1.5.23",
3+
"version": "1.5.24",
44
"author": "Ghislain B.",
55
"description": "Angular-Validation Directive and Service (ghiscoding)",
66
"main": [

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Angular-Validation change logs
22

3+
1.5.24 (2017-09-01) Fix #160, validate on empty not working in angular-service
34
1.5.23 (2017-08-17) Merged PR #162 and #163
45
1.5.22 (2017-06-07) Merged PR #157 to add Simplified Chinese locale.
56
1.5.21 (2017-05-14) Fix #151 validation rule "different" disables rule "required".

dist/angular-validation.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* Angular-Validation Directive and Service (ghiscoding)
33
* http://github.com/ghiscoding/angular-validation
44
* @author: Ghislain B.
5-
* @version: 1.5.23
5+
* @version: 1.5.24
66
* @license: MIT
7-
* @build: Thu Aug 17 2017 00:34:56 GMT-0400 (Eastern Daylight Time)
7+
* @build: Fri Sep 01 2017 23:43:13 GMT-0400 (Eastern Daylight Time)
88
*/
99
/**
1010
* Angular-Validation Directive (ghiscoding)
@@ -2842,18 +2842,14 @@ angular
28422842
attrs.name = attrs.elmName;
28432843

28442844
// user could pass his own scope, useful in a case of an isolate scope
2845-
if (!!self.validationAttrs.isolatedScope) {
2846-
var tempValidationOptions = scope.$validationOptions || null; // keep global validationOptions
2847-
scope = self.validationAttrs.isolatedScope; // rewrite original scope
2845+
if (!!self.validationAttrs.isolatedScope || attrs.isolatedScope) {
2846+
var tempValidationOptions = scope.$validationOptions || null; // keep global validationOptions
2847+
scope = self.validationAttrs.isolatedScope || attrs.isolatedScope; // rewrite original scope
28482848
if(!!tempValidationOptions) {
2849-
scope.$validationOptions = tempValidationOptions; // reuse the validationOption from original scope
2849+
scope.$validationOptions = tempValidationOptions; // reuse the validationOption from original scope
28502850
}
28512851
}
28522852

2853-
// Possible element attributes
2854-
_validationCallback = (self.validationAttrs.hasOwnProperty('validationCallback')) ? self.validationAttrs.validationCallback : null;
2855-
_validateOnEmpty = (self.validationAttrs.hasOwnProperty('validateOnEmpty')) ? self.commonObj.parseBool(self.validationAttrs.validateOnEmpty) : !!_globalOptions.validateOnEmpty;
2856-
28572853
// onBlur make validation without waiting
28582854
attrs.elm.bind('blur', _blurHandler = function(event) {
28592855
// get the form element custom object and use it after
@@ -2875,6 +2871,10 @@ angular
28752871
// so the position inside the mergeObject call is very important
28762872
attrs = self.commonObj.mergeObjects(self.validationAttrs, attrs);
28772873

2874+
// Possible element attributes
2875+
_validationCallback = (attrs.hasOwnProperty('validationCallback')) ? attrs.validationCallback : null;
2876+
_validateOnEmpty = (attrs.hasOwnProperty('validateOnEmpty')) ? self.commonObj.parseBool(attrs.validateOnEmpty) : !!_globalOptions.validateOnEmpty;
2877+
28782878
// watch the `disabled` attribute for changes
28792879
// if it become disabled then skip validation else it becomes enable then we need to revalidate it
28802880
watchNgDisabled(self, scope, attrs);

dist/angular-validation.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-validation-ghiscoding",
3-
"version": "1.5.23",
3+
"version": "1.5.24",
44
"author": "Ghislain B.",
55
"description": "Angular-Validation Directive and Service (ghiscoding)",
66
"main": "dist/angular-validation.min",

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Angular Validation (Directive / Service)
2-
`Version: 1.5.23`
2+
`Version: 1.5.24`
33
### Forms Validation with Angular made easy!
44
##### (Concept comes from the amazing Laravel)
55

src/validation-service.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,14 @@ angular
8888
attrs.name = attrs.elmName;
8989

9090
// user could pass his own scope, useful in a case of an isolate scope
91-
if (!!self.validationAttrs.isolatedScope) {
92-
var tempValidationOptions = scope.$validationOptions || null; // keep global validationOptions
93-
scope = self.validationAttrs.isolatedScope; // rewrite original scope
91+
if (!!self.validationAttrs.isolatedScope || attrs.isolatedScope) {
92+
var tempValidationOptions = scope.$validationOptions || null; // keep global validationOptions
93+
scope = self.validationAttrs.isolatedScope || attrs.isolatedScope; // rewrite original scope
9494
if(!!tempValidationOptions) {
95-
scope.$validationOptions = tempValidationOptions; // reuse the validationOption from original scope
95+
scope.$validationOptions = tempValidationOptions; // reuse the validationOption from original scope
9696
}
9797
}
9898

99-
// Possible element attributes
100-
_validationCallback = (self.validationAttrs.hasOwnProperty('validationCallback')) ? self.validationAttrs.validationCallback : null;
101-
_validateOnEmpty = (self.validationAttrs.hasOwnProperty('validateOnEmpty')) ? self.commonObj.parseBool(self.validationAttrs.validateOnEmpty) : !!_globalOptions.validateOnEmpty;
102-
10399
// onBlur make validation without waiting
104100
attrs.elm.bind('blur', _blurHandler = function(event) {
105101
// get the form element custom object and use it after
@@ -121,6 +117,10 @@ angular
121117
// so the position inside the mergeObject call is very important
122118
attrs = self.commonObj.mergeObjects(self.validationAttrs, attrs);
123119

120+
// Possible element attributes
121+
_validationCallback = (attrs.hasOwnProperty('validationCallback')) ? attrs.validationCallback : null;
122+
_validateOnEmpty = (attrs.hasOwnProperty('validateOnEmpty')) ? self.commonObj.parseBool(attrs.validateOnEmpty) : !!_globalOptions.validateOnEmpty;
123+
124124
// watch the `disabled` attribute for changes
125125
// if it become disabled then skip validation else it becomes enable then we need to revalidate it
126126
watchNgDisabled(self, scope, attrs);

0 commit comments

Comments
 (0)