diff --git a/app.js b/app.js
index ad37431..7ac0187 100644
--- a/app.js
+++ b/app.js
@@ -9,6 +9,10 @@ myApp.config(['$compileProvider', '$locationProvider', '$routeProvider', functio
templateUrl: 'templates/testingFormDirective.html',
controller: 'CtrlValidationDirective'
})
+ .when('/validate-2forms', {
+ templateUrl: 'templates/testing2Forms.html',
+ controller: 'Ctrl2forms'
+ })
.when('/validate-service', {
templateUrl: 'templates/testingFormService.html',
controller: 'CtrlValidationService'
@@ -54,6 +58,17 @@ myApp.controller('CtrlValidationDirective', ['$scope', 'validationService', func
}
}]);
+myApp.controller('Ctrl2forms', ['$scope', 'validationService', function ($scope, validationService) {
+ $scope.submitForm = function() {
+ if(new validationService().checkFormValidity($scope.form01)) {
+ alert('All good, proceed with submit...');
+ }
+ }
+ $scope.showValidationSummary = function () {
+ $scope.displayValidationSummary = true;
+ }
+}]);
+
// -- Controller to use Angular-Validation Service
// -----------------------------------------------
diff --git a/bower.json b/bower.json
index 36e59c9..9874cd9 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "ghiscoding.angular-validation",
- "version": "1.3.14",
+ "version": "1.3.15",
"authors": [
"Ghislain B."
],
diff --git a/changelog.txt b/changelog.txt
index 17fba6d..32050b4 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -15,4 +15,5 @@ Angular-Validation change logs
1.3.11 (2015-03-30): Accepted pull request #15 to fix form without name attribute. Also accepted pull request #18 to add Spanish locales.
1.3.12 (2015-04-04): Fix issue #16 and added Validators Alternate Text option on all type of validators. Also fixed removeValidator and clean a lot of code.
1.3.13 (2015-04-06) Fixed $translate delay issue when using external JSON files
-1.3.14 (2015-04-07) Merge pull request #19 Added norwegian translation and changes to allow user to remove invalid validators.
\ No newline at end of file
+1.3.14 (2015-04-07) Merge pull request #19 Added norwegian translation and changes to allow user to remove invalid validators.
+1.3.15 (2015-04-08) Fixed #23 If multiple forms exist in the app the errors in 1 form affect validation in the other
\ No newline at end of file
diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js
index 5a8b3a4..acb5e0a 100644
--- a/dist/angular-validation.min.js
+++ b/dist/angular-validation.min.js
@@ -2,11 +2,11 @@
* Angular-Validation Directive and Service (ghiscoding)
* http://github.com/ghiscoding/angular-validation
* @author: Ghislain B.
- * @version: 1.3.14
+ * @version: 1.3.15
* @license: MIT
- * @build: Wed Apr 08 2015 00:55:43 GMT-0400 (Eastern Daylight Time)
+ * @build: Thu Apr 09 2015 00:07:40 GMT-0400 (Eastern Daylight Time)
*/
angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$timeout","validationCommon","validationRules",function(i,t){return{restrict:"A",require:"ngModel",link:function(a,e,n,l){function d(){i.cancel(r),u.updateErrorMsg(""),l.$setValidity("validation",!0),e.unbind("blur")}function o(t){return u.validate(t,!1),u.isFieldRequired()||""!==t&&null!==t&&"undefined"!=typeof t?((u.isFieldRequired()||t)&&l.$setValidity("validation",!1),e.bind("blur",function(){return a.$evalAsync(l.$setValidity("validation",u.validate(t,!0))),t}),"SELECT"===e.prop("tagName").toUpperCase()?(l.$setValidity("validation",u.validate(t,!0)),t):("undefined"!=typeof t&&(u.updateErrorMsg(""),i.cancel(r),r=i(function(){a.$evalAsync(l.$setValidity("validation",u.validate(t,!0)))},u.typingLimit)),t)):(d(),t)}var r,u=new t(a,e,n,l);l.$parsers.unshift(o),l.$formatters.unshift(o),n.$observe("disabled",function(i){i?l.$setValidity("validation",!0):l.$setValidity("validation",u.validate(l.$viewValue,!0))})}}}]);
-angular.module("ghiscoding.validation").factory("validationCommon",["$filter","$timeout","$translate","validationRules",function(t,a,e,r){function i(){var t=this,a={};t.validators=[],t.typingLimit=E,t.validatorAttrs.hasOwnProperty("debounce")?t.typingLimit=parseInt(t.validatorAttrs.debounce,10):t.validatorAttrs.hasOwnProperty("typingLimit")&&(t.typingLimit=parseInt(t.validatorAttrs.typingLimit,10));var e=t.validatorAttrs.hasOwnProperty("rules")?t.validatorAttrs.rules:t.validatorAttrs.validation;if(e.indexOf("regex:")>=0){var i=e.match("regex:(.*?):regex");if(i.length<2)throw'Regex validator within the validation needs to be define with an opening "regex:" and a closing ":regex", please review your validator.';var l=i[1].split(":=");a={message:l[0],pattern:l[1]},e=e.replace(i[0],"regex:")}var s=e.split("|");if(s){t.bFieldRequired=e.indexOf("required")>=0?!0:!1;for(var n=0,o=s.length;o>n;n++){var d=s[n].split(":"),u=s[n].indexOf("alt=")>=0?!0:!1;t.validators[n]=r.getElementValidators({altText:u===!0?2===d.length?d[1]:d[2]:"",customRegEx:a,rule:d[0],ruleParams:u&&2===d.length?null:d[1]})}}return t}function l(t){return g(R,"fieldName",t)}function s(){return R}function n(t,a,e,r){this.scope=t,this.elm=a,this.ctrl=r,this.validatorAttrs=e,v(a,e,r),this.defineValidation()}function o(){var t=this;return t.bFieldRequired}function d(t,a){var e=f(t,"field",a);e>=0&&t.splice(e,1)}function u(t,a){var r=this;a&&a.obj&&(r=a.obj,r.validatorAttrs=a.obj.attrs);var i=a&&a.elm?a.elm:r.elm,l=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof l||null===l)throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+i.attr("ng-model")+'"';var s=a&&a.translate?e(t):t,n=l.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,""),o=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var d=r.validatorAttrs.validationErrorTo.charAt(0),u="."===d||"#"===d?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;o=angular.element(document.querySelector(u))}o&&0!==o.length||(o=angular.element(document.querySelector(".validation-"+n)));var p=a&&a.isSubmitted?a.isSubmitted:!1;a&&!a.isValid&&(p||r.ctrl.$dirty||r.ctrl.$touched)?o.length>0?o.text(s):i.after(''+s+""):o.text("")}function p(t,a){for(var r,i=this,s=!0,n=!0,o="",d=0,u=i.validators.length;u>d;d++){if("conditionalDate"===i.validators[d].type){if(r=new RegExp(i.validators[d].pattern,"i"),n="\\S+"!==i.validators[d].pattern||"undefined"!=typeof t&&null!==t?r.test(t):!1){var p=i.validators[d].dateType,v=b(t,p).getTime();if(2==i.validators[d].params.length){var m=b(i.validators[d].params[0],p).getTime(),g=b(i.validators[d].params[1],p).getTime(),f=O(i.validators[d].condition[0],v,m),h=O(i.validators[d].condition[1],v,g);n=f&&h?!0:!1}else{var y=b(i.validators[d].params[0],p).getTime();n=O(i.validators[d].condition,v,y)}}}else if("conditionalNumber"===i.validators[d].type)if(2==i.validators[d].params.length){var f=O(i.validators[d].condition[0],parseFloat(t),parseFloat(i.validators[d].params[0])),h=O(i.validators[d].condition[1],parseFloat(t),parseFloat(i.validators[d].params[1]));n=f&&h?!0:!1}else n=O(i.validators[d].condition,parseFloat(t),parseFloat(i.validators[d].params[0]));else if("match"===i.validators[d].type){var E=i.validators[d].params[0],R=i.scope.$eval(E);n=R===t}else i.elm.prop("disabled")||1==parseInt(i.elm.attr("ng-disabled"))||"true"===i.elm.attr("ng-disabled")?n=!0:"string"==typeof t&&""===t&&"NUMBER"===i.elm.prop("type").toUpperCase()?(o=e("INVALID_KEY_CHAR"),n=!1):(r=new RegExp(i.validators[d].pattern,"i"),n="\\S+"!==i.validators[d].pattern||"undefined"!=typeof t&&null!==t?r.test(t):!1);if((!i.bFieldRequired&&!t||i.elm.prop("disabled")||1==parseInt(i.elm.attr("ng-disabled"))||"true"===i.elm.attr("ng-disabled"))&&(n=!0),!n&&(s=!1,o+=" ",o+=i.validators[d].altText&&i.validators[d].altText.length>0?i.validators[d].altText.replace("alt=",""):e(i.validators[d].message),"undefined"!=typeof i.validators[d].params))for(var S=0,A=i.validators[d].params.length;A>S;S++)"match"===i.validators[d].type&&A>1&&0===S||(o=o.replace(":param",i.validators[d].params[S]))}o=o.trim(),c(i,e(o));var x=l(i.elm.attr("name"));return x&&(x.isValid=n,x.message=e(o)),a&&i.updateErrorMsg(o,{isValid:s}),s}function v(t,a,e){var r={fieldName:t.attr("name"),elm:t,attrs:a,ctrl:e,isValid:!1,message:""},i=f(R,"fieldName",t.attr("name"));return i>=0?R[i]=r:R.push(r),R}function m(t){var a=f(R,"fieldName",t);a>=0&&R.splice(a,1)}function c(t,a){var e=t.elm.attr("name"),r=f(S,"field",e);if(r>=0&&""===a)S.splice(r,1);else if(""!==a){var i={field:e,message:a};r>=0?S[r]=i:S.push(i)}t.scope.$validationSummary=S;var l=h(t);l&&(l.$validationSummary=S)}function g(t,a,e){for(var r=0;r8?t.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":e=t.substring(0,8),r=t.substring(2,3),i=y(e,r),o=i[0],n=i[1],s=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],l=t.length>8?t.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":e=t.substring(0,10),r=t.substring(2,3),i=y(e,r),n=i[0],o=i[1],s=i[2],l=t.length>8?t.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":e=t.substring(0,8),r=t.substring(2,3),i=y(e,r),n=i[0],o=i[1],s=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],l=t.length>8?t.substring(9).split(":"):null;break;case"ISO":default:e=t.substring(0,10),r=t.substring(4,5),i=y(e,r),s=i[0],n=i[1],o=i[2],l=t.length>10?t.substring(11).split(":"):null}var d=l&&3===l.length?l[0]:0,u=l&&3===l.length?l[1]:0,p=l&&3===l.length?l[2]:0;return new Date(s,n-1,o,d,u,p)}function y(t,a){var e=[];switch(a){case"/":e=t.split("/");break;case".":e=t.split(".");break;case"-":default:e=t.split("-")}return e}function O(t,a,e){var r=!1;switch(t){case"<":r=e>a?!0:!1;break;case"<=":r=e>=a?!0:!1;break;case">":r=a>e?!0:!1;break;case">=":r=a>=e?!0:!1;break;case"!=":case"<>":r=a!=e?!0:!1;break;case"=":case"==":r=a==e?!0:!1;break;default:r=!1}return r}var E=1e3,R=[],S=[],e=t("translate"),A=function(t,a,e,r){this.timer=null,this.bFieldRequired=!1,this.validators=[],this.typingLimit=E,this.scope=t,this.elm=a,this.ctrl=r,this.validatorAttrs=e,t&&a&&e&&r&&(v(a,e,r),this.defineValidation())};return A.prototype.defineValidation=i,A.prototype.getFormElementByName=l,A.prototype.getFormElements=s,A.prototype.isFieldRequired=o,A.prototype.initialize=n,A.prototype.removeFromValidationSummary=d,A.prototype.updateErrorMsg=u,A.prototype.validate=p,A.prototype.removeFromFormElementObjectList=m,A}]);
-angular.module("ghiscoding.validation").factory("validationRules",[function(){function e(e){var a="undefined"!=typeof e.altText?e.altText.replace("alt=",""):null,t=e.hasOwnProperty("customRegEx")?e.customRegEx:null,s=e.hasOwnProperty("rule")?e.rule:null,r=e.hasOwnProperty("ruleParams")?e.ruleParams:null,n={};switch(s){case"alpha":n={pattern:"^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$",message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":n={pattern:"^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\\s])+$",message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":n={pattern:"^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$",message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":n={pattern:"^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\\s])+$",message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":n={pattern:"^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ_-])+$",message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":n={pattern:"^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\\s_-])+$",message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"betweenLen":case"between_len":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";n={pattern:"^.{"+_[0]+","+_[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[_[0],_[1]],type:"regex"};break;case"betweenNum":case"between_num":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";n={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"conditionalNumber"};break;case"creditCard":case"credit_card":n={pattern:"^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|6(?:011|5[0-9]{2})[0-9]{12}|(?:2131|1800|35\\d{3})\\d{11})$",message:"INVALID_CREDIT_CARD",type:"regex"};break;case"dateEuroLong":case"date_euro_long":n={pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/](19|20)\\d\\d$",message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";n={condition:[">=","<="],dateType:"EURO_LONG",params:[_[0],_[1]],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/](19|20)\\d\\d$",message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":n={condition:"<=",dateType:"EURO_LONG",params:[r],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/](19|20)\\d\\d$",message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":n={condition:">=",dateType:"EURO_LONG",params:[r],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/](19|20)\\d\\d$",message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":n={pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/]\\d\\d$",message:"INVALID_DATE_EURO_SHORT",type:"regex"};break;case"dateEuroShortBetween":case"date_euro_short_between":case"betweenDateEuroShort":case"between_date_euro_short":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";n={condition:[">=","<="],dateType:"EURO_SHORT",params:[_[0],_[1]],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/]\\d\\d$",message:"INVALID_DATE_EURO_SHORT_BETWEEN",type:"conditionalDate"};break;case"dateEuroShortMax":case"date_euro_short_max":case"maxDateEuroShort":case"max_date_euro_short":n={condition:"<=",dateType:"EURO_SHORT",params:[r],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/]\\d\\d$",message:"INVALID_DATE_EURO_SHORT_MAX",type:"conditionalDate"};break;case"dateEuroShortMin":case"date_euro_short_min":case"minDateEuroShort":case"min_date_euro_short":n={condition:">=",dateType:"EURO_SHORT",params:[r],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/]\\d\\d$",message:"INVALID_DATE_EURO_SHORT_MIN",type:"conditionalDate"};break;case"dateIso":case"date_iso":n={pattern:"^(19|20)\\d\\d([-])(0[1-9]|1[012])\\2(0[1-9]|[12][0-9]|3[01])$",message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";n={condition:[">=","<="],dateType:"ISO",params:[_[0],_[1]],pattern:"^(19|20)\\d\\d([-])(0[1-9]|1[012])\\2(0[1-9]|[12][0-9]|3[01])$",message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":n={condition:"<=",dateType:"ISO",params:[r],pattern:"^(19|20)\\d\\d([-])(0[1-9]|1[012])\\2(0[1-9]|[12][0-9]|3[01])$",message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":n={condition:">=",dateType:"ISO",params:[r],pattern:"^(19|20)\\d\\d([-])(0[1-9]|1[012])\\2(0[1-9]|[12][0-9]|3[01])$",message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":n={pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/](19|20)\\d\\d$",message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";n={condition:[">=","<="],dateType:"US_LONG",params:[_[0],_[1]],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/](19|20)\\d\\d$",message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":n={condition:"<=",dateType:"US_LONG",params:[r],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/](19|20)\\d\\d$",message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":n={condition:">=",dateType:"US_LONG",params:[r],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/](19|20)\\d\\d$",message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":n={pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/]\\d\\d$",message:"INVALID_DATE_US_SHORT",type:"regex"};break;case"dateUsShortBetween":case"date_us_short_between":case"betweenDateUsShort":case"between_date_us_short":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";n={condition:[">=","<="],dateType:"US_SHORT",params:[_[0],_[1]],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/]\\d\\d$",message:"INVALID_DATE_US_SHORT_BETWEEN",type:"conditionalDate"};break;case"dateUsShortMax":case"date_us_short_max":case"maxDateUsShort":case"max_date_us_short":n={condition:"<=",dateType:"US_SHORT",params:[r],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/]\\d\\d$",message:"INVALID_DATE_US_SHORT_MAX",type:"conditionalDate"};break;case"dateUsShortMin":case"date_us_short_min":case"minDateUsShort":case"min_date_us_short":n={condition:">=",dateType:"US_SHORT",params:[r],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/]\\d\\d$",message:"INVALID_DATE_US_SHORT_MIN",type:"conditionalDate"};break;case"email":n={pattern:"^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$",message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":n={pattern:"^.{"+r+"}$",message:"INVALID_EXACT_LEN",params:[r],type:"regex"};break;case"float":n={pattern:"^\\d*\\.{1}\\d+$",message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":n={pattern:"^[-+]?\\d*\\.{1}\\d+$",message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":n={pattern:"[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}",message:"INVALID_IBAN",type:"regex"};break;case"int":case"integer":n={pattern:"^\\d+$",message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":n={pattern:"^[+-]?\\d+$",message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ipv4":n={pattern:"^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$",message:"INVALID_IPV4",type:"regex"};break;case"ipv6":n={pattern:"^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$",message:"INVALID_IPV6",type:"regex"};break;case"ipv6_hex":n={pattern:"^((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)$",message:"INVALID_IPV6_HEX",type:"regex"};break;case"match":var e=r.split(",");n={message:"INVALID_INPUT_MATCH",params:e,type:"match"};break;case"maxLen":case"max_len":n={pattern:"^.{0,"+r+"}$",message:"INVALID_MAX_CHAR",params:[r],type:"regex"};break;case"maxNum":case"max_num":n={condition:"<=",message:"INVALID_MAX_NUM",params:[r],type:"conditionalNumber"};break;case"minLen":case"min_len":n={pattern:"^.{"+r+",}$",message:"INVALID_MIN_CHAR",params:[r],type:"regex"};break;case"minNum":case"min_num":n={condition:">=",message:"INVALID_MIN_NUM",params:[r],type:"conditionalNumber"};break;case"numeric":n={pattern:"^\\d*\\.?\\d+$",message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":n={pattern:"^[-+]?\\d*\\.?\\d+$",message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"regex":n={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"required":n={pattern:"\\S+",message:"INVALID_REQUIRED",type:"regex"};break;case"url":n={pattern:"(http|ftp|https):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?",message:"INVALID_URL",type:"regex"};break;case"time":n={pattern:"^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$",message:"INVALID_TIME",type:"regex"}}return n.altText=a,n}var a={getElementValidators:e};return a}]);
+angular.module("ghiscoding.validation").factory("validationCommon",["$filter","$timeout","$translate","validationRules",function(t,a,e,r){function i(){var t=this,a={};t.validators=[],t.typingLimit=R,t.validatorAttrs.hasOwnProperty("debounce")?t.typingLimit=parseInt(t.validatorAttrs.debounce,10):t.validatorAttrs.hasOwnProperty("typingLimit")&&(t.typingLimit=parseInt(t.validatorAttrs.typingLimit,10));var e=t.validatorAttrs.hasOwnProperty("rules")?t.validatorAttrs.rules:t.validatorAttrs.validation;if(e.indexOf("regex:")>=0){var i=e.match("regex:(.*?):regex");if(i.length<2)throw'Regex validator within the validation needs to be define with an opening "regex:" and a closing ":regex", please review your validator.';var l=i[1].split(":=");a={message:l[0],pattern:l[1]},e=e.replace(i[0],"regex:")}var n=e.split("|");if(n){t.bFieldRequired=e.indexOf("required")>=0?!0:!1;for(var s=0,o=n.length;o>s;s++){var d=n[s].split(":"),u=n[s].indexOf("alt=")>=0?!0:!1;t.validators[s]=r.getElementValidators({altText:u===!0?2===d.length?d[1]:d[2]:"",customRegEx:a,rule:d[0],ruleParams:u&&2===d.length?null:d[1]})}}return t}function l(t){return g(x,"fieldName",t)}function n(){return x}function s(t,a,e,r){this.scope=t,this.elm=a,this.ctrl=r,this.validatorAttrs=e,v(a,e,r),this.defineValidation()}function o(){var t=this;return t.bFieldRequired}function d(t,a){var e=h(t,"field",a);e>=0&&t.splice(e,1)}function u(t,a){var r=this;a&&a.obj&&(r=a.obj,r.validatorAttrs=a.obj.attrs);var i=a&&a.elm?a.elm:r.elm,l=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof l||null===l)throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+i.attr("ng-model")+'"';var n=a&&a.translate?e(t):t,s=l.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,""),o=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var d=r.validatorAttrs.validationErrorTo.charAt(0),u="."===d||"#"===d?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;o=angular.element(document.querySelector(u))}o&&0!==o.length||(o=angular.element(document.querySelector(".validation-"+s)));var p=a&&a.isSubmitted?a.isSubmitted:!1;a&&!a.isValid&&(p||r.ctrl.$dirty||r.ctrl.$touched)?o.length>0?o.text(n):i.after(''+n+""):o.text("")}function p(t,a){for(var r,i=this,n=!0,s=!0,o="",d=0,u=i.validators.length;u>d;d++){if("conditionalDate"===i.validators[d].type){if(r=new RegExp(i.validators[d].pattern,"i"),s="\\S+"!==i.validators[d].pattern||"undefined"!=typeof t&&null!==t?r.test(t):!1){var p=i.validators[d].dateType,v=y(t,p).getTime();if(2==i.validators[d].params.length){var m=y(i.validators[d].params[0],p).getTime(),g=y(i.validators[d].params[1],p).getTime(),f=O(i.validators[d].condition[0],v,m),h=O(i.validators[d].condition[1],v,g);s=f&&h?!0:!1}else{var b=y(i.validators[d].params[0],p).getTime();s=O(i.validators[d].condition,v,b)}}}else if("conditionalNumber"===i.validators[d].type)if(2==i.validators[d].params.length){var f=O(i.validators[d].condition[0],parseFloat(t),parseFloat(i.validators[d].params[0])),h=O(i.validators[d].condition[1],parseFloat(t),parseFloat(i.validators[d].params[1]));s=f&&h?!0:!1}else s=O(i.validators[d].condition,parseFloat(t),parseFloat(i.validators[d].params[0]));else if("match"===i.validators[d].type){var E=i.validators[d].params[0],R=i.scope.$eval(E);s=R===t}else i.elm.prop("disabled")||1==parseInt(i.elm.attr("ng-disabled"))||"true"===i.elm.attr("ng-disabled")?s=!0:"string"==typeof t&&""===t&&"NUMBER"===i.elm.prop("type").toUpperCase()?(o=e("INVALID_KEY_CHAR"),s=!1):(r=new RegExp(i.validators[d].pattern,"i"),s="\\S+"!==i.validators[d].pattern||"undefined"!=typeof t&&null!==t?r.test(t):!1);if((!i.bFieldRequired&&!t||i.elm.prop("disabled")||1==parseInt(i.elm.attr("ng-disabled"))||"true"===i.elm.attr("ng-disabled"))&&(s=!0),!s&&(n=!1,o+=" ",o+=i.validators[d].altText&&i.validators[d].altText.length>0?i.validators[d].altText.replace("alt=",""):e(i.validators[d].message),"undefined"!=typeof i.validators[d].params))for(var x=0,S=i.validators[d].params.length;S>x;x++)"match"===i.validators[d].type&&S>1&&0===x||(o=o.replace(":param",i.validators[d].params[x]))}o=o.trim(),c(i,e(o));var A=l(i.elm.attr("name"));return A&&(A.isValid=s,A.message=e(o)),a&&i.updateErrorMsg(o,{isValid:n}),n}function v(t,a,e){var r={fieldName:t.attr("name"),elm:t,attrs:a,ctrl:e,isValid:!1,message:""},i=h(x,"fieldName",t.attr("name"));return i>=0?x[i]=r:x.push(r),x}function m(t){var a=h(x,"fieldName",t);a>=0&&x.splice(a,1)}function c(t,a){var e=t.elm.attr("name"),r=b(t),i=h(S,"field",e);if(i>=0&&""===a)S.splice(i,1);else if(""!==a){var l={field:e,message:a,formName:r?r.$name:null};i>=0?S[i]=l:S.push(l)}t.scope.$validationSummary=S,r&&(r.$validationSummary=f(S,"formName",r.$name))}function g(t,a,e){for(var r=0;r8?t.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":e=t.substring(0,8),r=t.substring(2,3),i=E(e,r),o=i[0],s=i[1],n=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],l=t.length>8?t.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":e=t.substring(0,10),r=t.substring(2,3),i=E(e,r),s=i[0],o=i[1],n=i[2],l=t.length>8?t.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":e=t.substring(0,8),r=t.substring(2,3),i=E(e,r),s=i[0],o=i[1],n=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],l=t.length>8?t.substring(9).split(":"):null;break;case"ISO":default:e=t.substring(0,10),r=t.substring(4,5),i=E(e,r),n=i[0],s=i[1],o=i[2],l=t.length>10?t.substring(11).split(":"):null}var d=l&&3===l.length?l[0]:0,u=l&&3===l.length?l[1]:0,p=l&&3===l.length?l[2]:0;return new Date(n,s-1,o,d,u,p)}function E(t,a){var e=[];switch(a){case"/":e=t.split("/");break;case".":e=t.split(".");break;case"-":default:e=t.split("-")}return e}function O(t,a,e){var r=!1;switch(t){case"<":r=e>a?!0:!1;break;case"<=":r=e>=a?!0:!1;break;case">":r=a>e?!0:!1;break;case">=":r=a>=e?!0:!1;break;case"!=":case"<>":r=a!=e?!0:!1;break;case"=":case"==":r=a==e?!0:!1;break;default:r=!1}return r}var R=1e3,x=[],S=[],e=t("translate"),A=function(t,a,e,r){this.timer=null,this.bFieldRequired=!1,this.validators=[],this.typingLimit=R,this.scope=t,this.elm=a,this.ctrl=r,this.validatorAttrs=e,t&&a&&e&&r&&(v(a,e,r),this.defineValidation())};return A.prototype.defineValidation=i,A.prototype.getFormElementByName=l,A.prototype.getFormElements=n,A.prototype.isFieldRequired=o,A.prototype.initialize=s,A.prototype.removeFromValidationSummary=d,A.prototype.updateErrorMsg=u,A.prototype.validate=p,A.prototype.removeFromFormElementObjectList=m,A}]);
+angular.module("ghiscoding.validation").factory("validationRules",[function(){function e(e){var a="undefined"!=typeof e.altText?e.altText.replace("alt=",""):null,t=e.hasOwnProperty("customRegEx")?e.customRegEx:null,s=e.hasOwnProperty("rule")?e.rule:null,r=e.hasOwnProperty("ruleParams")?e.ruleParams:null,n={};switch(s){case"alpha":n={pattern:"^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$",message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":n={pattern:"^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\\s])+$",message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":n={pattern:"^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$",message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":n={pattern:"^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\\s])+$",message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":n={pattern:"^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ_-])+$",message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":n={pattern:"^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\\s_-])+$",message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"betweenLen":case"between_len":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";n={pattern:"^.{"+_[0]+","+_[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[_[0],_[1]],type:"regex"};break;case"betweenNum":case"between_num":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";n={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"conditionalNumber"};break;case"creditCard":case"credit_card":n={pattern:"^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|6(?:011|5[0-9]{2})[0-9]{12}|(?:2131|1800|35\\d{3})\\d{11})$",message:"INVALID_CREDIT_CARD",type:"regex"};break;case"dateEuroLong":case"date_euro_long":n={pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/](19|20)\\d\\d$",message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";n={condition:[">=","<="],dateType:"EURO_LONG",params:[_[0],_[1]],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/](19|20)\\d\\d$",message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":n={condition:"<=",dateType:"EURO_LONG",params:[r],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/](19|20)\\d\\d$",message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":n={condition:">=",dateType:"EURO_LONG",params:[r],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/](19|20)\\d\\d$",message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":n={pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/]\\d\\d$",message:"INVALID_DATE_EURO_SHORT",type:"regex"};break;case"dateEuroShortBetween":case"date_euro_short_between":case"betweenDateEuroShort":case"between_date_euro_short":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";n={condition:[">=","<="],dateType:"EURO_SHORT",params:[_[0],_[1]],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/]\\d\\d$",message:"INVALID_DATE_EURO_SHORT_BETWEEN",type:"conditionalDate"};break;case"dateEuroShortMax":case"date_euro_short_max":case"maxDateEuroShort":case"max_date_euro_short":n={condition:"<=",dateType:"EURO_SHORT",params:[r],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/]\\d\\d$",message:"INVALID_DATE_EURO_SHORT_MAX",type:"conditionalDate"};break;case"dateEuroShortMin":case"date_euro_short_min":case"minDateEuroShort":case"min_date_euro_short":n={condition:">=",dateType:"EURO_SHORT",params:[r],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/]\\d\\d$",message:"INVALID_DATE_EURO_SHORT_MIN",type:"conditionalDate"};break;case"dateIso":case"date_iso":n={pattern:"^(19|20)\\d\\d([-])(0[1-9]|1[012])\\2(0[1-9]|[12][0-9]|3[01])$",message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";n={condition:[">=","<="],dateType:"ISO",params:[_[0],_[1]],pattern:"^(19|20)\\d\\d([-])(0[1-9]|1[012])\\2(0[1-9]|[12][0-9]|3[01])$",message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":n={condition:"<=",dateType:"ISO",params:[r],pattern:"^(19|20)\\d\\d([-])(0[1-9]|1[012])\\2(0[1-9]|[12][0-9]|3[01])$",message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":n={condition:">=",dateType:"ISO",params:[r],pattern:"^(19|20)\\d\\d([-])(0[1-9]|1[012])\\2(0[1-9]|[12][0-9]|3[01])$",message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":n={pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/](19|20)\\d\\d$",message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";n={condition:[">=","<="],dateType:"US_LONG",params:[_[0],_[1]],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/](19|20)\\d\\d$",message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":n={condition:"<=",dateType:"US_LONG",params:[r],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/](19|20)\\d\\d$",message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":n={condition:">=",dateType:"US_LONG",params:[r],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/](19|20)\\d\\d$",message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":n={pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/]\\d\\d$",message:"INVALID_DATE_US_SHORT",type:"regex"};break;case"dateUsShortBetween":case"date_us_short_between":case"betweenDateUsShort":case"between_date_us_short":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";n={condition:[">=","<="],dateType:"US_SHORT",params:[_[0],_[1]],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/]\\d\\d$",message:"INVALID_DATE_US_SHORT_BETWEEN",type:"conditionalDate"};break;case"dateUsShortMax":case"date_us_short_max":case"maxDateUsShort":case"max_date_us_short":n={condition:"<=",dateType:"US_SHORT",params:[r],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/]\\d\\d$",message:"INVALID_DATE_US_SHORT_MAX",type:"conditionalDate"};break;case"dateUsShortMin":case"date_us_short_min":case"minDateUsShort":case"min_date_us_short":n={condition:">=",dateType:"US_SHORT",params:[r],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/]\\d\\d$",message:"INVALID_DATE_US_SHORT_MIN",type:"conditionalDate"};break;case"email":n={pattern:"^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$",message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":n={pattern:"^.{"+r+"}$",message:"INVALID_EXACT_LEN",params:[r],type:"regex"};break;case"float":n={pattern:"^\\d*\\.{1}\\d+$",message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":n={pattern:"^[-+]?\\d*\\.{1}\\d+$",message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":n={pattern:"[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}",message:"INVALID_IBAN",type:"regex"};break;case"int":case"integer":n={pattern:"^\\d+$",message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":n={pattern:"^[+-]?\\d+$",message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ipv4":n={pattern:"^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$",message:"INVALID_IPV4",type:"regex"};break;case"ipv6":n={pattern:"^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$",message:"INVALID_IPV6",type:"regex"};break;case"ipv6_hex":n={pattern:"^((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)$",message:"INVALID_IPV6_HEX",type:"regex"};break;case"match":var e=r.split(",");n={message:"INVALID_INPUT_MATCH",params:e,type:"match"};break;case"maxLen":case"max_len":n={pattern:"^.{0,"+r+"}$",message:"INVALID_MAX_CHAR",params:[r],type:"regex"};break;case"maxNum":case"max_num":n={condition:"<=",message:"INVALID_MAX_NUM",params:[r],type:"conditionalNumber"};break;case"minLen":case"min_len":n={pattern:"^.{"+r+",}$",message:"INVALID_MIN_CHAR",params:[r],type:"regex"};break;case"minNum":case"min_num":n={condition:">=",message:"INVALID_MIN_NUM",params:[r],type:"conditionalNumber"};break;case"numeric":n={pattern:"^\\d*\\.?\\d+$",message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":n={pattern:"^[-+]?\\d*\\.?\\d+$",message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"regex":n={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"required":n={pattern:"\\S+",message:"INVALID_REQUIRED",type:"regex"};break;case"url":n={pattern:"(http|ftp|https):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?",message:"INVALID_URL",type:"regex"};break;case"time":n={pattern:"^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$",message:"INVALID_TIME",type:"regex"};break;case"checked":n={pattern:"^true$",message:"INVALID_CHECKBOX_SELECTED",type:"regex"}}return n.altText=a,n}var a={getElementValidators:e};return a}]);
angular.module("ghiscoding.validation").service("validationService",["$timeout","validationCommon",function(e,o){function t(e,o){var t=this,i={};if("string"==typeof e&&"string"==typeof o?(i.elmName=e,i.rules=o):i=e,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof t.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";return i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]:not([disabled]):not([ng-disabled]')),"object"!=typeof i.elm||0===i.elm.length?t:(i.elm.bind("blur",function(e){t.commonObj.initialize(i.scope,i.elm,i,i.ctrl),t.commonObj.typingLimit=0,m(t,e.target.value)}),i=c(t.validationAttrs,i),i.scope.$watch(i.elmName,function(e,o){return void 0===e&&void 0!==o?void t.commonObj.updateErrorMsg("INVALID_KEY_CHAR",{valid:!1,translate:!0}):(i.ctrl=angular.element(i.elm).controller("ngModel"),i.value=e,t.commonObj.initialize(i.scope,i.elm,i,i.ctrl),void m(t,e))},!0),t)}function i(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope object passed as argument to function properly (ex.: $scope.form1 OR $scope).";for(var t=[],i=0,n=e.$validationSummary.length;n>i;i++)t.push(e.$validationSummary[i].field);for(i=0,n=t.length;n>i;i++)t[i]&&(o.commonObj.removeFromFormElementObjectList(t[i]),o.commonObj.removeFromValidationSummary(e.$validationSummary,t[i]))}function n(e){var o=this,t="",i=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope object passed as argument to function properly (ex.: $scope.form1 OR $scope).";for(var n=0,a=e.$validationSummary.length;a>n;n++)if(i=!1,t=e.$validationSummary[n].field){var r=o.commonObj.getFormElementByName(t);r.elm&&r.elm.length>0&&(r.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:r.isValid,obj:r}))}return i}function a(e,o){var t=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope object passed as argument to function properly (ex.: $scope.form1 OR $scope).";var i;if(o instanceof Array)for(var n=0,a=o.length;a>n;n++)i=t.commonObj.getFormElementByName(o[n]),d(t,i,e.$validationSummary);else i=t.commonObj.getFormElementByName(o),d(t,i,e.$validationSummary)}function r(e){var o=this;return o.validationAttrs=e,o}function m(o,t){return o.commonObj.validate(t,!1),o.commonObj.isFieldRequired()||""!==t&&null!==t&&"undefined"!=typeof t?((o.commonObj.isFieldRequired()||t)&&o.commonObj.ctrl.$setValidity("validation",!1),"SELECT"===o.commonObj.elm.prop("tagName").toUpperCase()?(o.commonObj.ctrl.$setValidity("validation",o.commonObj.validate(t,!0)),t):("undefined"!=typeof t&&(o.commonObj.updateErrorMsg(""),e.cancel(o.timer),o.timer=e(function(){o.commonObj.scope.$evalAsync(o.commonObj.ctrl.$setValidity("validation",o.commonObj.validate(t,!0)))},o.commonObj.typingLimit)),t)):(l(o),t)}function l(o){e.cancel(self.timer),o.commonObj.updateErrorMsg(""),o.commonObj.ctrl.$setValidity("validation",!0),o.commonObj.elm.unbind("blur")}function c(e,o){var t={};for(var i in e)t[i]=e[i];for(var i in o)t[i]=o[i];return t}function d(e,o,t){if("undefined"!=typeof e.commonObj.scope){var i=e.commonObj.scope.$watch(o.fieldName,function(){});i(),o.elm.unbind(),o.ctrl.$setUntouched(),o.ctrl.$setPristine(),o.ctrl.$setValidity("validation",!0),e.commonObj.removeFromValidationSummary(t,o.fieldName),e.commonObj.updateErrorMsg("",{isValid:!0,obj:o})}}var s=function(){this.validationAttrs={},this.commonObj=new o};return s.prototype.addValidator=t,s.prototype.checkFormValidity=n,s.prototype.removeValidator=a,s.prototype.setGlobalOptions=r,s.prototype.clearInvalidValidatorsInSummary=i,s}]);
\ No newline at end of file
diff --git a/index.html b/index.html
index 0db8d87..68f5d9a 100644
--- a/index.html
+++ b/index.html
@@ -27,6 +27,7 @@
Angular-Validation Directive|Service (ghiscoding)
+
diff --git a/locales/validation/en.json b/locales/validation/en.json
index fcfa1c1..3f0015b 100644
--- a/locales/validation/en.json
+++ b/locales/validation/en.json
@@ -51,7 +51,7 @@
"INVALID_REQUIRED": "Field is required. ",
"INVALID_URL": "Must be a valid URL. ",
"INVALID_TIME": "Must be a valid time format (hh:mm) OR (hh:mm:ss). ",
- "INVALID_CHECKBOX_SELECTED": "Checkbox must be selected",
+ "INVALID_CHECKBOX_SELECTED": "Checkbox must be selected. ",
"AREA1": "TextArea: Alphanumeric + Minimum(15) + Required",
"ERRORS": "Errors",
diff --git a/locales/validation/es.json b/locales/validation/es.json
index 6e78919..4764a14 100644
--- a/locales/validation/es.json
+++ b/locales/validation/es.json
@@ -51,7 +51,7 @@
"INVALID_REQUIRED": "El campo es requerido. ",
"INVALID_URL": "Debe contener una dirección URL valida. ",
"INVALID_TIME": "Debe contener un formato de tiempo valido (hh:mm) ó (hh:mm:ss). ",
- "INVALID_CHECKBOX_SELECTED": "Checkbox must be selected",
+ "INVALID_CHECKBOX_SELECTED": "Casilla de verificación debe ser seleccionado. ",
"AREA1": "Area de texto: Alfanúmerica + Minimo(15) + Requerido",
"ERRORS": "Errores",
diff --git a/locales/validation/fr.json b/locales/validation/fr.json
index 5b8308d..447a1ca 100644
--- a/locales/validation/fr.json
+++ b/locales/validation/fr.json
@@ -51,7 +51,7 @@
"INVALID_REQUIRED": "Le champ est requis. ",
"INVALID_URL": "Doit être un URL valide. ",
"INVALID_TIME": "Doit être un format de date valide (hh:mm) OU (hh:mm:ss). ",
- "INVALID_CHECKBOX_SELECTED": "Checkbox must be selected",
+ "INVALID_CHECKBOX_SELECTED": "La case à cocher doit être sélectionnée. ",
"AREA1": "TextArea: Alphanumérique + Minimum(15) + Required",
"ERRORS": "Erreurs",
diff --git a/package.json b/package.json
index 6ef7406..475ae1e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "ghiscoding.angular-validation",
- "version": "1.3.14",
+ "version": "1.3.15",
"author": "Ghislain B.",
"description": "Angular-Validation Directive and Service (ghiscoding)",
"main": "app.js",
diff --git a/readme.md b/readme.md
index d05d4bf..9befba2 100644
--- a/readme.md
+++ b/readme.md
@@ -1,5 +1,5 @@
#Angular Validation (Directive / Service)
-`Version: 1.3.14`
+`Version: 1.3.15`
### Form validation after user inactivity of default 1sec. (customizable timeout)
Forms Validation with Angular made easy! Angular-Validation is an angular directive/service with locales (languages) with a very simple approach of defining your `validation=""` directly within your element to validate (input, textarea, etc) and...that's it!!! The directive/service will take care of the rest!
@@ -459,4 +459,5 @@ License
* [1.3.11](https://github.com/ghiscoding/angular-validation/commit/e807584f0bcdf0f28ef2ef905b6bc4e890926ac1) `2015-03-30` Accepted pull request #15 to fix form without name attribute. Also accepted pull request #18 to add Spanish locales.
* [1.3.12](https://github.com/ghiscoding/angular-validation/commit/0af82337a6961923e3b022a19660237d3e6f7184) `2015-04-04` Fix issue #16 and added Validators Alternate Text option on all type of validators. Also fixed removeValidator and clean a lot of code.
* [1.3.13](https://github.com/ghiscoding/angular-validation/commit/d0440bdd7fc2816e03d28ad3a9c3bd7bee8ac519) `2015-04-06` Fixed $translate delay issue when using external JSON files
-* [1.3.14](https://github.com/ghiscoding/angular-validation/pull/19) `2015-04-07` Merge pull request #19 Added norwegian translation and changes to allow user to remove invalid validators
\ No newline at end of file
+* [1.3.14](https://github.com/ghiscoding/angular-validation/pull/19) `2015-04-07` Merge pull request #19 Added norwegian translation and changes to allow user to remove invalid validators
+* [1.3.15]() `2015-04-08` Fixed #23 If multiple forms exist in the app the errors in 1 form affect validation in the other
\ No newline at end of file
diff --git a/src/validation-common.js b/src/validation-common.js
index ebd7f54..ab7dbf1 100644
--- a/src/validation-common.js
+++ b/src/validation-common.js
@@ -26,6 +26,7 @@ angular
var validators = []; // Array of all Form Validators
var validatorAttrs = {}; // Current Validator attributes
var validationSummary = []; // Array Validation Error Summary
+ var validationSummaries = {}; // Validation Error Summaries separated by Form (could be multiple forms)
var $translate = $filter('translate');
// service constructor
@@ -396,13 +397,14 @@ angular
*/
function addToValidationSummary(self, message) {
var elmName = self.elm.attr('name');
- var index = arrayFindObjectIndex(validationSummary, 'field', elmName); // find index of object in our array
+ var form = getElementParentForm(self); // find the parent form (only found if it has a name)
+ var index = arrayFindObjectIndex(validationSummary, 'field', elmName); // find index of object in our array
// if message is empty, remove it from the validation summary
if(index >= 0 && message === '') {
validationSummary.splice(index, 1);
}else if(message !== '') {
- var errorObj = { field: elmName, message: message };
+ var errorObj = { field: elmName, message: message, formName: (!!form) ? form.$name : null };
// if error already exist then refresh the error object inside the array, else push it to the array
if(index >= 0) {
@@ -412,11 +414,14 @@ angular
}
}
- // save validation summary 2 variable locations, inside the scope object and also in the form object (if found)
+ // save validation summary scope root
self.scope.$validationSummary = validationSummary;
- var form = getScopeForm(self);
+
+ // and also save it inside the current scope form (if found)
if (!!form) {
- form.$validationSummary = validationSummary;
+ // since validationSummary contain errors of all forms
+ // we need to find only the errors of current form and them into the current scope form object
+ form.$validationSummary = arrayFindObjects(validationSummary, 'formName', form.$name);
}
}
@@ -435,6 +440,22 @@ angular
return null;
}
+ /** Quick function to find all object(s) inside an array of objects by it's given field name and value, return array of object found(s) or empty array
+ * @param Array sourceArray
+ * @param string searchId: search property id
+ * @param string searchValue: value to search
+ * @return array of object found from source array
+ */
+ function arrayFindObjects(sourceArray, searchId, searchValue) {
+ var results = [];
+ for (var i = 0; i < sourceArray.length; i++) {
+ if (sourceArray[i][searchId] === searchValue) {
+ results.push(sourceArray[i]);
+ }
+ }
+ return results;
+ }
+
/** Quick function to find an object inside an array by it's given field name and value, return the index position found or -1
* @param Array sourceArray
* @param string searchId: search property id
@@ -450,6 +471,24 @@ angular
return -1;
}
+ /** Get the element's parent Angular form (if found)
+ * @param object self
+ * @return object scope form
+ */
+ function getElementParentForm(self) {
+ // from the element passed, get his parent form
+ var elmName = self.elm.attr('name');
+ var forms = document.getElementsByName(elmName);
+
+ for (var i = 0; i < forms.length; i++) {
+ var form = forms[i].form;
+ if (!!form && form.name && self.scope[form.name]) {
+ return self.scope[form.name];
+ }
+ }
+ return null;
+ }
+
/** Get form within scope (if found)
* @param object self
* @return object scope form
diff --git a/src/validation-service.js b/src/validation-service.js
index 45ed6f4..d0a34c1 100644
--- a/src/validation-service.js
+++ b/src/validation-service.js
@@ -28,8 +28,8 @@ angular
validationService.prototype.checkFormValidity = checkFormValidity; // check the form validity (can be called by an empty validationService and used by both Directive/Service)
validationService.prototype.removeValidator = removeValidator; // remove a Validator from an element
validationService.prototype.setGlobalOptions = setGlobalOptions; // set and initialize global options used by all validators
- validationService.prototype.clearInvalidValidatorsInSummary = clearInvalidValidatorsInSummary; // clear clearInvalidValidatorsInSummary
-
+ validationService.prototype.clearInvalidValidatorsInSummary = clearInvalidValidatorsInSummary; // clear clearInvalidValidatorsInSummary
+
return validationService;
//----
@@ -93,9 +93,9 @@ angular
} // addValidator()
/** Remove all objects in validationsummary and matching objects in FormElementList.
- * This is for use in a wizard type setting, where you 'move back' to a previous page in wizard.
+ * This is for use in a wizard type setting, where you 'move back' to a previous page in wizard.
* In this case you need to remove invalid validators that will exist in 'the future'.
- * @param object Angular Form or Scope Object
+ * @param object Angular Form or Scope Object
*/
function clearInvalidValidatorsInSummary(obj) {
var self = this;
diff --git a/templates/testing2Forms.html b/templates/testing2Forms.html
new file mode 100644
index 0000000..0073273
--- /dev/null
+++ b/templates/testing2Forms.html
@@ -0,0 +1,66 @@
+