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

Commit

Permalink
fix #160 validate on empty validation-service
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Sep 2, 2017
1 parent e7ff68c commit 2da6923
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-validation-ghiscoding",
"version": "1.5.23",
"version": "1.5.24",
"author": "Ghislain B.",
"description": "Angular-Validation Directive and Service (ghiscoding)",
"main": [
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Angular-Validation change logs

1.5.24 (2017-09-01) Fix #160, validate on empty not working in angular-service
1.5.23 (2017-08-17) Merged PR #162 and #163
1.5.22 (2017-06-07) Merged PR #157 to add Simplified Chinese locale.
1.5.21 (2017-05-14) Fix #151 validation rule "different" disables rule "required".
Expand Down
20 changes: 10 additions & 10 deletions dist/angular-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* Angular-Validation Directive and Service (ghiscoding)
* http://github.com/ghiscoding/angular-validation
* @author: Ghislain B.
* @version: 1.5.23
* @version: 1.5.24
* @license: MIT
* @build: Thu Aug 17 2017 00:34:56 GMT-0400 (Eastern Daylight Time)
* @build: Fri Sep 01 2017 23:43:13 GMT-0400 (Eastern Daylight Time)
*/
/**
* Angular-Validation Directive (ghiscoding)
Expand Down Expand Up @@ -2842,18 +2842,14 @@ angular
attrs.name = attrs.elmName;

// user could pass his own scope, useful in a case of an isolate scope
if (!!self.validationAttrs.isolatedScope) {
var tempValidationOptions = scope.$validationOptions || null; // keep global validationOptions
scope = self.validationAttrs.isolatedScope; // rewrite original scope
if (!!self.validationAttrs.isolatedScope || attrs.isolatedScope) {
var tempValidationOptions = scope.$validationOptions || null; // keep global validationOptions
scope = self.validationAttrs.isolatedScope || attrs.isolatedScope; // rewrite original scope
if(!!tempValidationOptions) {
scope.$validationOptions = tempValidationOptions; // reuse the validationOption from original scope
scope.$validationOptions = tempValidationOptions; // reuse the validationOption from original scope
}
}

// Possible element attributes
_validationCallback = (self.validationAttrs.hasOwnProperty('validationCallback')) ? self.validationAttrs.validationCallback : null;
_validateOnEmpty = (self.validationAttrs.hasOwnProperty('validateOnEmpty')) ? self.commonObj.parseBool(self.validationAttrs.validateOnEmpty) : !!_globalOptions.validateOnEmpty;

// onBlur make validation without waiting
attrs.elm.bind('blur', _blurHandler = function(event) {
// get the form element custom object and use it after
Expand All @@ -2875,6 +2871,10 @@ angular
// so the position inside the mergeObject call is very important
attrs = self.commonObj.mergeObjects(self.validationAttrs, attrs);

// Possible element attributes
_validationCallback = (attrs.hasOwnProperty('validationCallback')) ? attrs.validationCallback : null;
_validateOnEmpty = (attrs.hasOwnProperty('validateOnEmpty')) ? self.commonObj.parseBool(attrs.validateOnEmpty) : !!_globalOptions.validateOnEmpty;

// watch the `disabled` attribute for changes
// if it become disabled then skip validation else it becomes enable then we need to revalidate it
watchNgDisabled(self, scope, attrs);
Expand Down
6 changes: 3 additions & 3 deletions dist/angular-validation.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-validation-ghiscoding",
"version": "1.5.23",
"version": "1.5.24",
"author": "Ghislain B.",
"description": "Angular-Validation Directive and Service (ghiscoding)",
"main": "dist/angular-validation.min",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Angular Validation (Directive / Service)
`Version: 1.5.23`
`Version: 1.5.24`
### Forms Validation with Angular made easy!
##### (Concept comes from the amazing Laravel)

Expand Down
16 changes: 8 additions & 8 deletions src/validation-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,14 @@ angular
attrs.name = attrs.elmName;

// user could pass his own scope, useful in a case of an isolate scope
if (!!self.validationAttrs.isolatedScope) {
var tempValidationOptions = scope.$validationOptions || null; // keep global validationOptions
scope = self.validationAttrs.isolatedScope; // rewrite original scope
if (!!self.validationAttrs.isolatedScope || attrs.isolatedScope) {
var tempValidationOptions = scope.$validationOptions || null; // keep global validationOptions
scope = self.validationAttrs.isolatedScope || attrs.isolatedScope; // rewrite original scope
if(!!tempValidationOptions) {
scope.$validationOptions = tempValidationOptions; // reuse the validationOption from original scope
scope.$validationOptions = tempValidationOptions; // reuse the validationOption from original scope
}
}

// Possible element attributes
_validationCallback = (self.validationAttrs.hasOwnProperty('validationCallback')) ? self.validationAttrs.validationCallback : null;
_validateOnEmpty = (self.validationAttrs.hasOwnProperty('validateOnEmpty')) ? self.commonObj.parseBool(self.validationAttrs.validateOnEmpty) : !!_globalOptions.validateOnEmpty;

// onBlur make validation without waiting
attrs.elm.bind('blur', _blurHandler = function(event) {
// get the form element custom object and use it after
Expand All @@ -121,6 +117,10 @@ angular
// so the position inside the mergeObject call is very important
attrs = self.commonObj.mergeObjects(self.validationAttrs, attrs);

// Possible element attributes
_validationCallback = (attrs.hasOwnProperty('validationCallback')) ? attrs.validationCallback : null;
_validateOnEmpty = (attrs.hasOwnProperty('validateOnEmpty')) ? self.commonObj.parseBool(attrs.validateOnEmpty) : !!_globalOptions.validateOnEmpty;

// watch the `disabled` attribute for changes
// if it become disabled then skip validation else it becomes enable then we need to revalidate it
watchNgDisabled(self, scope, attrs);
Expand Down

0 comments on commit 2da6923

Please sign in to comment.