From 2f8570b8362ae71c58462235f778cfb15fe3476b Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Tue, 14 Jun 2016 23:27:15 -0400 Subject: [PATCH 01/60] Fixed issue #121 alternate text containing char ":" The char ":" is used for splitting arguments in validation, but it shouldn't be split when it is part of an alternate text. --- bower.json | 2 +- dist/angular-validation.min.js | 6 +- more-examples/ngModelOptionBlur/app.js | 36 +++++++++ more-examples/ngModelOptionBlur/index.html | 85 ++++++++++++++++++++++ package.json | 2 +- readme.md | 2 +- src/validation-common.js | 17 ++++- 7 files changed, 140 insertions(+), 10 deletions(-) create mode 100644 more-examples/ngModelOptionBlur/app.js create mode 100644 more-examples/ngModelOptionBlur/index.html diff --git a/bower.json b/bower.json index 4ce2cff..a235b83 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.1", + "version": "1.5.2", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 06dd6a3..266c441 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.5.1 + * @version: 1.5.2 * @license: MIT - * @build: Thu Mar 10 2016 19:36:12 GMT-0500 (Eastern Standard Time) + * @build: Tue Jun 14 2016 23:09:36 GMT-0400 (Eastern Daylight Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,l,r){function o(i,l){var o=a.defer(),d=!1,m="undefined"!=typeof l?l:$.typingLimit,s=$.getFormElementByName(r.$name);if(Array.isArray(i)){if(O=[],E="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||w||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||w)&&r.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),r.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===l?(d=$.validate(i,!0),n.$evalAsync(r.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(r.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(C){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){E.length>0&&g.displayOnlyLastErrorMsg?E="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):E+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(E,{isValid:!1}),$.addToValidationSummary(a.formElmObj,E)});break;case"one":default:a.isFieldValid===!0&&(r.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(r.$name),i="undefined"!=typeof r.$modelValue?r.$modelValue:a.target.value;if(e.isValidationCancelled)r.$setValidity("validation",!0);else{var n=o(i,0);F&&$.runValidationCallbackOnPromise(n,F)}}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var l in t)if(t.hasOwnProperty(l)){if(A&&l!==A)continue;d(t[l],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(h,"elmName",r.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();h.shift()}}function f(){var a=$.getFormElementByName(r.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),r.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){return y()?{badInput:!0}:r.$modelValue},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);F&&$.runValidationCallbackOnPromise(i,F)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(r.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=r.$modelValue||"";Array.isArray(a)||r.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(r.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,l,r),E="",O=[],h=[],g=$.getGlobalOptions(),j=l.name,F=l.hasOwnProperty("validationCallback")?l.validationCallback:null,w=l.hasOwnProperty("validateOnEmpty")?$.parseBool(l.validateOnEmpty):!!g.validateOnEmpty,C=l.hasOwnProperty("validArrayRequireHowMany")?l.validArrayRequireHowMany:"one",A=l.hasOwnProperty("validationArrayObjprop")?l.validationArrayObjprop:null;h.push({elmName:j,watcherHandler:v()}),l.$observe("disabled",function(a){a?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(h,"elmName",r.$name);e||h.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==r.$name){r.revalidateCalled=!0;var i=r.$modelValue;if(t.isValidationCancelled)r.$setValidity("validation",!0);else{var n=o(i);F&&$.runValidationCallbackOnPromise(n,F)}}})}}}]); -angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function i(e,t,r){if("undefined"!=typeof e&&null!=e){var i=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),n=E(i,e),o=w(z,"field",i);if(o>=0&&""===t)z.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:i,friendlyName:s,message:t,formName:n?n.$name:null};o>=0?z[o]=l:z.push(l)}if(e.scope.$validationSummary=z,n&&(n.$validationSummary=A(z,"formName",n.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,n&&n.$name)){var d=n.$name.indexOf(".")>=0?n.$name.split(".")[1]:n.$name,p=_.controllerAs[d]?_.controllerAs[d]:e.elm.controller()[d];p&&(p.$validationSummary=A(z,"formName",n.$name))}return z}}function n(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var i=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!i||i.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var n=i[1],o=i[2]?i[2].replace(/\|(.*)/,""):"",s=n.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+n,"pattern")}else if(a.indexOf("regex:")>=0){var i=a.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 d=i[1].split(":=");t={message:d[0],pattern:d[1]},a=a.replace(i[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var u=0,m=p.length;m>u;u++){var c=p[u].split(":"),f=p[u].indexOf("alt=")>=0;e.validators[u]=r.getElementValidators({altText:f===!0?2===c.length?c[1]:c[2]:"",customRegEx:t,rule:c[0],ruleParams:f&&2===c.length?null:c[1]})}}return e}function o(e){return V(B,"fieldName",e)}function s(e){return e?A(B,"formName",e):B}function l(){return _}function d(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,O(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function u(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=w(B,"fieldName",e);t>=0&&B.splice(t,1)}function c(e,t){var a=this,r=E(e,a),i=t||z,n=w(i,"field",e);if(n>=0&&i.splice(n,1),n=w(z,"field",e),n>=0&&z.splice(n,1),a.scope.$validationSummary=z,r&&(r.$validationSummary=A(z,"formName",r.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;_.controllerAs[o]&&(_.controllerAs[o].$validationSummary=A(z,"formName",r.$name))}return z}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){_.displayOnlyLastErrorMsg=e}function y(e){var t=this;return _=u(_,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var i=t&&t.elm?t.elm:r.elm,n=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof n||null===n){var o=i?i.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=n.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),d=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),u="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;d=angular.element(document.querySelector(u))}d&&0!==d.length||(d=angular.element(document.querySelector(".validation-"+l)));var m=t&&t.isSubmitted?t.isSubmitted:!1;!_.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?d.length>0?d.html(s):i.after('
'+s+"
"):d.html("")}function b(e,t){var r,n=this,s=!0,l=!0,d=0,p={message:""};"undefined"==typeof e&&(e="");for(var u=n.ctrl&&n.ctrl.$name?n.ctrl.$name:n.attrs&&n.attrs.name?n.attrs.name:n.elm.attr("name"),m=o(u),c=n.validatorAttrs.rules||n.validatorAttrs.validation,f=0,g=n.validators.length;g>f;f++){r=n.validators[f],"autoDetect"===r.type&&(r=D(r,e));var v=n.attrs?n.attrs.ngDisabled:n.validatorAttrs.ngDisabled;switch(r.type){case"conditionalDate":s=C(e,r,c);break;case"conditionalNumber":s=U(e,r);break;case"javascript":s=j(e,r,n,m,t,p);break;case"matching":s=G(e,r,n,p);break;case"remote":s=H(e,r,n,m,t,p);break;default:s=P(e,r,c,n)}if((!n.bFieldRequired&&!e&&!K||n.elm.prop("disabled")||n.scope.$eval(v))&&(s=!0),s||(l=!1,function(e,r,i){var o=i.message,s=_.errorMessageSeparator||" ";i.altText&&i.altText.length>0&&(o=i.altText.replace("alt=",""));var d=a(o);e.translatePromise=d,e.validator=i,d.then(function(a){p.message.length>0&&_.displayOnlyLastErrorMsg?p.message=s+(i&&i.params?String.format(a,i.params):a):p.message+=s+(i&&i.params?String.format(a,i.params):a),$(n,e,p.message,l,t)})["catch"](function(a){i.altText&&i.altText.length>0&&(p.message.length>0&&_.displayOnlyLastErrorMsg?p.message=s+o:p.message+=s+o,$(n,e,p.message,l,t))})}(m,s,r)),s&&d++,n.validRequireHowMany==d&&s){l=!0;break}}return s&&(i(n,""),n.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function O(e,t,r,i){var n=t.name?t.name:e.attr("name"),o=E(n,{scope:i}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:n,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:i,isValid:!1,message:"",formName:o?o.$name:null},d=w(B,"fieldName",e.attr("name"));return d>=0?B[d]=l:B.push(l),B}function $(e,t,a,r,n){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(_.preValidateValidationSummary||"undefined"==typeof _.preValidateValidationSummary||n)&&i(t,a),(e.validatorAttrs.preValidateFormElements||_.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),n&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&i(t,"")}function S(e){return e.typingLimit=I,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):_&&_.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(_.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:_.validRequireHowMany,K=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):_.validateOnEmpty,e}function V(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(n){var o=n?n.getAttribute("name"):null;if(o){var s={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(_&&_.controllerAs&&o.indexOf(".")>=0){var l=o.split(".");return t.scope[l[0]][l[1]]=s}return t.scope[o]=s}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,i=0,n=r.length;n>i;i++)e[r[i]]&&(e=e[r[i]]);return e}function N(e){return"boolean"==typeof e||"number"==typeof e?e===!0||1===e:"string"==typeof e&&(e=e.replace(/^\s+|\s+$/g,"").toLowerCase(),"true"===e||"1"===e||"false"===e||"0"===e)?"true"===e||"1"===e:void 0}function T(e,t){var a="",r="-",i=[],n=[],o="",s="",l="";switch(t.toUpperCase()){case"EURO_LONG":case"EURO-LONG":a=e.substring(0,10),r=e.substring(2,3),i=q(a,r),l=i[0],s=i[1],o=i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),l=i[0],s=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),i=q(a,r),o=i[0],s=i[1],l=i[2],n=e.length>10?e.substring(11).split(":"):null}var d=n&&3===n.length?n[0]:0,p=n&&3===n.length?n[1]:0,u=n&&3===n.length?n[2]:0;return new Date(o,s-1,l,d,p,u)}function q(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function F(e,t,a){var r=!1;switch(e){case"<":r=a>t;break;case"<=":r=a>=t;break;case">":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function k(){return this.replace(/^\s+|\s+$/g,"")}function L(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function M(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function C(e,t,a){var r=!0,i=r=!1;if(e instanceof Date)i=!0;else{var n=new RegExp(t.pattern,t.patternFlag);i=(!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e?!1:n.test(e)}if(i){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),d=T(t.params[1],o).getTime(),p=F(t.condition[0],s,l),u=F(t.condition[1],s,d);r=p&&u}else{var m=T(t.params[0],o).getTime();r=F(t.condition,s,m)}}return r}function U(e,t){var a=!0;if(2==t.params.length){var r=F(t.condition[0],parseFloat(e),parseFloat(t.params[0])),i=F(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&i}else a=F(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function j(e,a,r,i,n,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",d="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||K){var p=a.params[0],u=f(r,p);if("boolean"==typeof u)s=!!u;else{if("object"!=typeof u)throw d;s=!!u.isValid}if(s===!1?(i.isValid=!1,t(function(){var e=o.message+" ";if(u.message&&(e+=u.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;$(r,i,e,!1,n)})):s===!0&&(i.isValid=!0,$(r,i,"",!0,n)),"undefined"==typeof u)throw d}return s}function G(e,t,r,i){var n=!0,s=t.params[0],l=r.scope.$eval(s),d=angular.element(document.querySelector('[name="'+s+'"]')),p=t,u=r.ctrl,m=o(r.ctrl.$name);return n=F(t.condition,e,l)&&!!e,d&&d.attr("friendly-name")?t.params[1]=d.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var n=F(p.condition,u.$viewValue,e);if(e!==t){if(n)$(r,m,"",!0,!0);else{m.isValid=!1;var o=p.message;p.altText&&p.altText.length>0&&(o=p.altText.replace("alt=","")),a(o).then(function(e){var t=_.errorMessageSeparator||" ";i.message=t+(p&&p.params?String.format(e,p.params):e),$(r,m,i.message,n,!0)})}u.$setValidity("validation",n)}},!0),n}function H(e,t,a,r,i,n){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&i||K){a.ctrl.$processing=!0;var d=t.params[0],p=f(a,d);if(J.length>1)for(;J.length>0;){var u=J.pop();"function"==typeof u.abort&&u.abort()}if(J.push(p),!p||"function"!=typeof p.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,J.pop(),a.ctrl.$processing=!1;var d=n.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,d+=t.message||e," "===d)throw s;$(a,r,d,!1,i)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),$(a,r,"",!0,i))})}(t.altText)}return o}function P(e,t,a,r){var i=!0,n=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(n))i=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())i=!1;else{var o=new RegExp(t.pattern,t.patternFlag);i=(!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e?!1:o.test(e)}return i}function D(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var I=1e3,B=[],_={resetGlobalOptionsOnRouteChange:!0},J=[],z=[],K=!1;e.$on("$routeChangeStart",function(e,t,a){_.resetGlobalOptionsOnRouteChange&&(_={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},B=[],z=[])});var Y=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=I,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(_=e.$validationOptions),e&&(_.isolatedScope||_.scope)&&(this.scope=_.isolatedScope||_.scope,_=u(e.$validationOptions,_)),"undefined"==typeof _.resetGlobalOptionsOnRouteChange&&(_.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&(O(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return Y.prototype.addToValidationSummary=i,Y.prototype.arrayFindObject=V,Y.prototype.defineValidation=n,Y.prototype.getFormElementByName=o,Y.prototype.getFormElements=s,Y.prototype.getGlobalOptions=l,Y.prototype.isFieldRequired=p,Y.prototype.initialize=d,Y.prototype.mergeObjects=u,Y.prototype.parseBool=N,Y.prototype.removeFromValidationSummary=c,Y.prototype.removeFromFormElementObjectList=m,Y.prototype.runValidationCallbackOnPromise=g,Y.prototype.setDisplayOnlyLastErrorMsg=v,Y.prototype.setGlobalOptions=y,Y.prototype.updateErrorMsg=h,Y.prototype.validate=b,String.prototype.trim=k,String.prototype.format=L,String.format=M,Y}]); +angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function i(e,t,r){if("undefined"!=typeof e&&null!=e){var i=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),n=E(i,e),o=w(z,"field",i);if(o>=0&&""===t)z.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:i,friendlyName:s,message:t,formName:n?n.$name:null};o>=0?z[o]=l:z.push(l)}if(e.scope.$validationSummary=z,n&&(n.$validationSummary=A(z,"formName",n.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,n&&n.$name)){var d=n.$name.indexOf(".")>=0?n.$name.split(".")[1]:n.$name,u=_.controllerAs[d]?_.controllerAs[d]:e.elm.controller()[d];u&&(u.$validationSummary=A(z,"formName",n.$name))}return z}}function n(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var i=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!i||i.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var n=i[1],o=i[2]?i[2].replace(/\|(.*)/,""):"",s=n.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+n,"pattern")}else if(a.indexOf("regex:")>=0){var i=a.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 d=i[1].split(":=");t={message:d[0],pattern:d[1]},a=a.replace(i[0],"regex:")}var u=a.split("|");if(u){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=u.length;m>p;p++){var c=u[p].indexOf("alt="),f=c>=0,g=[];f?(g=u[p].substring(0,c-1).split(":"),g.push(u[p].substring(c))):g=u[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return V(B,"fieldName",e)}function s(e){return e?A(B,"formName",e):B}function l(){return _}function d(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,O(t,a,r,e),this.defineValidation()}function u(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=w(B,"fieldName",e);t>=0&&B.splice(t,1)}function c(e,t){var a=this,r=E(e,a),i=t||z,n=w(i,"field",e);if(n>=0&&i.splice(n,1),n=w(z,"field",e),n>=0&&z.splice(n,1),a.scope.$validationSummary=z,r&&(r.$validationSummary=A(z,"formName",r.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;_.controllerAs[o]&&(_.controllerAs[o].$validationSummary=A(z,"formName",r.$name))}return z}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){_.displayOnlyLastErrorMsg=e}function y(e){var t=this;return _=p(_,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var i=t&&t.elm?t.elm:r.elm,n=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof n||null===n){var o=i?i.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=n.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),d=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var u=r.validatorAttrs.validationErrorTo.charAt(0),p="."===u||"#"===u?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;d=angular.element(document.querySelector(p))}d&&0!==d.length||(d=angular.element(document.querySelector(".validation-"+l)));var m=t&&t.isSubmitted?t.isSubmitted:!1;!_.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?d.length>0?d.html(s):i.after('
'+s+"
"):d.html("")}function b(e,t){var r,n=this,s=!0,l=!0,d=0,u={message:""};"undefined"==typeof e&&(e="");for(var p=n.ctrl&&n.ctrl.$name?n.ctrl.$name:n.attrs&&n.attrs.name?n.attrs.name:n.elm.attr("name"),m=o(p),c=n.validatorAttrs.rules||n.validatorAttrs.validation,f=0,g=n.validators.length;g>f;f++){r=n.validators[f],"autoDetect"===r.type&&(r=D(r,e));var v=n.attrs?n.attrs.ngDisabled:n.validatorAttrs.ngDisabled;switch(r.type){case"conditionalDate":s=C(e,r,c);break;case"conditionalNumber":s=U(e,r);break;case"javascript":s=j(e,r,n,m,t,u);break;case"matching":s=G(e,r,n,u);break;case"remote":s=H(e,r,n,m,t,u);break;default:s=P(e,r,c,n)}if((!n.bFieldRequired&&!e&&!K||n.elm.prop("disabled")||n.scope.$eval(v))&&(s=!0),s||(l=!1,function(e,r,i){var o=i.message,s=_.errorMessageSeparator||" ";i.altText&&i.altText.length>0&&(o=i.altText.replace("alt=",""));var d=a(o);e.translatePromise=d,e.validator=i,d.then(function(a){u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+(i&&i.params?String.format(a,i.params):a):u.message+=s+(i&&i.params?String.format(a,i.params):a),$(n,e,u.message,l,t)})["catch"](function(a){i.altText&&i.altText.length>0&&(u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+o:u.message+=s+o,$(n,e,u.message,l,t))})}(m,s,r)),s&&d++,n.validRequireHowMany==d&&s){l=!0;break}}return s&&(i(n,""),n.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function O(e,t,r,i){var n=t.name?t.name:e.attr("name"),o=E(n,{scope:i}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:n,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:i,isValid:!1,message:"",formName:o?o.$name:null},d=w(B,"fieldName",e.attr("name"));return d>=0?B[d]=l:B.push(l),B}function $(e,t,a,r,n){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(_.preValidateValidationSummary||"undefined"==typeof _.preValidateValidationSummary||n)&&i(t,a),(e.validatorAttrs.preValidateFormElements||_.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),n&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&i(t,"")}function S(e){return e.typingLimit=I,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):_&&_.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(_.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:_.validRequireHowMany,K=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):_.validateOnEmpty,e}function V(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(n){var o=n?n.getAttribute("name"):null;if(o){var s={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(_&&_.controllerAs&&o.indexOf(".")>=0){var l=o.split(".");return t.scope[l[0]][l[1]]=s}return t.scope[o]=s}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,i=0,n=r.length;n>i;i++)e[r[i]]&&(e=e[r[i]]);return e}function N(e){return"boolean"==typeof e||"number"==typeof e?e===!0||1===e:"string"==typeof e&&(e=e.replace(/^\s+|\s+$/g,"").toLowerCase(),"true"===e||"1"===e||"false"===e||"0"===e)?"true"===e||"1"===e:void 0}function T(e,t){var a="",r="-",i=[],n=[],o="",s="",l="";switch(t.toUpperCase()){case"EURO_LONG":case"EURO-LONG":a=e.substring(0,10),r=e.substring(2,3),i=q(a,r),l=i[0],s=i[1],o=i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),l=i[0],s=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),i=q(a,r),o=i[0],s=i[1],l=i[2],n=e.length>10?e.substring(11).split(":"):null}var d=n&&3===n.length?n[0]:0,u=n&&3===n.length?n[1]:0,p=n&&3===n.length?n[2]:0;return new Date(o,s-1,l,d,u,p)}function q(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function F(e,t,a){var r=!1;switch(e){case"<":r=a>t;break;case"<=":r=a>=t;break;case">":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function k(){return this.replace(/^\s+|\s+$/g,"")}function L(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function M(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function C(e,t,a){var r=!0,i=r=!1;if(e instanceof Date)i=!0;else{var n=new RegExp(t.pattern,t.patternFlag);i=(!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e?!1:n.test(e)}if(i){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),d=T(t.params[1],o).getTime(),u=F(t.condition[0],s,l),p=F(t.condition[1],s,d);r=u&&p}else{var m=T(t.params[0],o).getTime();r=F(t.condition,s,m)}}return r}function U(e,t){var a=!0;if(2==t.params.length){var r=F(t.condition[0],parseFloat(e),parseFloat(t.params[0])),i=F(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&i}else a=F(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function j(e,a,r,i,n,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",d="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||K){var u=a.params[0],p=f(r,u);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw d;s=!!p.isValid}if(s===!1?(i.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;$(r,i,e,!1,n)})):s===!0&&(i.isValid=!0,$(r,i,"",!0,n)),"undefined"==typeof p)throw d}return s}function G(e,t,r,i){var n=!0,s=t.params[0],l=r.scope.$eval(s),d=angular.element(document.querySelector('[name="'+s+'"]')),u=t,p=r.ctrl,m=o(r.ctrl.$name);return n=F(t.condition,e,l)&&!!e,d&&d.attr("friendly-name")?t.params[1]=d.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var n=F(u.condition,p.$viewValue,e);if(e!==t){if(n)$(r,m,"",!0,!0);else{m.isValid=!1;var o=u.message;u.altText&&u.altText.length>0&&(o=u.altText.replace("alt=","")),a(o).then(function(e){var t=_.errorMessageSeparator||" ";i.message=t+(u&&u.params?String.format(e,u.params):e),$(r,m,i.message,n,!0)})}p.$setValidity("validation",n)}},!0),n}function H(e,t,a,r,i,n){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&i||K){a.ctrl.$processing=!0;var d=t.params[0],u=f(a,d);if(J.length>1)for(;J.length>0;){var p=J.pop();"function"==typeof p.abort&&p.abort()}if(J.push(u),!u||"function"!=typeof u.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){u.then(function(t){t=t.data||t,J.pop(),a.ctrl.$processing=!1;var d=n.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,d+=t.message||e," "===d)throw s;$(a,r,d,!1,i)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),$(a,r,"",!0,i))})}(t.altText)}return o}function P(e,t,a,r){var i=!0,n=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(n))i=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())i=!1;else{var o=new RegExp(t.pattern,t.patternFlag);i=(!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e?!1:o.test(e)}return i}function D(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var I=1e3,B=[],_={resetGlobalOptionsOnRouteChange:!0},J=[],z=[],K=!1;e.$on("$routeChangeStart",function(e,t,a){_.resetGlobalOptionsOnRouteChange&&(_={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},B=[],z=[])});var Y=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=I,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(_=e.$validationOptions),e&&(_.isolatedScope||_.scope)&&(this.scope=_.isolatedScope||_.scope,_=p(e.$validationOptions,_)),"undefined"==typeof _.resetGlobalOptionsOnRouteChange&&(_.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&(O(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return Y.prototype.addToValidationSummary=i,Y.prototype.arrayFindObject=V,Y.prototype.defineValidation=n,Y.prototype.getFormElementByName=o,Y.prototype.getFormElements=s,Y.prototype.getGlobalOptions=l,Y.prototype.isFieldRequired=u,Y.prototype.initialize=d,Y.prototype.mergeObjects=p,Y.prototype.parseBool=N,Y.prototype.removeFromValidationSummary=c,Y.prototype.removeFromFormElementObjectList=m,Y.prototype.runValidationCallbackOnPromise=g,Y.prototype.setDisplayOnlyLastErrorMsg=v,Y.prototype.setGlobalOptions=y,Y.prototype.updateErrorMsg=h,Y.prototype.validate=b,String.prototype.trim=k,String.prototype.format=L,String.format=M,Y}]); 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"accepted":n={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":n={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":n={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":n={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":n={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":n={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":n={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";n={patternLength:"^(.|[\\r\\n]){"+_[0]+","+_[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"autoDetect"};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:"^(.|[\\r\\n]){"+_[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"boolean":n={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":n={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":n={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":n={message:"",params:[r],type:"javascript"};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"different":case"differentInput":case"different_input":var e=r.split(",");n={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":n={pattern:"^\\d{"+r+"}$",message:"INVALID_DIGITS",params:[r],type:"regex"};break;case"digitsBetween":case"digits_between":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";n={pattern:"^\\d{"+_[0]+","+_[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[_[0],_[1]],type:"regex"};break;case"email":n={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":n={pattern:"^(.|[\\r\\n]){"+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}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"in":case"inList":case"in_list":var c=RegExp().escape(r).replace(/,/g,"|");n={pattern:"^("+c+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[r],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"ip":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:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"match":case"matchInput":case"match_input":case"same":var e=r.split(",");n={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":n={patternLength:"^(.|[\\r\\n]){0,"+r+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[r],type:"autoDetect"};break;case"maxLen":case"max_len":n={pattern:"^(.|[\\r\\n]){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"min":n={patternLength:"^(.|[\\r\\n]){"+r+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[r],type:"autoDetect"};break;case"minLen":case"min_len":n={pattern:"^(.|[\\r\\n]){"+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"notIn":case"not_in":case"notInList":case"not_in_list":var c=RegExp().escape(r).replace(/,/g,"|");n={pattern:"^((?!("+c+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[r],type:"regex"};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"phone":n={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"pattern":case"regex":n={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":n={message:"",params:[r],type:"remote"};break;case"required":n={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":n={patternLength:"^(.|[\\r\\n]){"+r+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[r],type:"autoDetect"};break;case"url":n={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,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}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e){var o=this,t="",a=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var n=0,i=e.$validationSummary.length;i>n;n++)if(a=!1,t=e.$validationSummary[n].field){var l=o.commonObj.getFormElementByName(t);l&&l.elm&&l.elm.length>0&&("function"==typeof l.ctrl.$setTouched&&l.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:l.isValid,obj:l}))}return a}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;n>a;a++)t.push(e.$validationSummary[a].field);for(a=0,n=t.length;n>a;a++)t[a]&&(o.commonObj.removeFromFormElementObjectList(t[a]),o.commonObj.removeFromValidationSummary(t[a],e.$validationSummary))}function m(e,o){var t,a=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"removeValidator() only works with Validation that were defined by the Service (not by the Directive) and requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";if(o instanceof Array)for(var n=0,i=o.length;i>n;n++)t=a.commonObj.getFormElementByName(o[n]),t.elm.removeAttr("validation"),b(a,t,e.$validationSummary);else o instanceof Object&&o.formElmObj?(t=o.formElmObj,t.elm.removeAttr("validation"),b(o.self,t,e.$validationSummary)):(t=a.commonObj.getFormElementByName(o),t.elm.removeAttr("validation"),b(a,t,e.$validationSummary));return a}function r(e,o){var t,a=this,o=o||{},n="undefined"!=typeof o.removeAllValidators?o.removeAllValidators:!1,i="undefined"!=typeof o.emptyAllInputValues?o.emptyAllInputValues:!1;if("undefined"==typeof e||"undefined"==typeof e.$name)throw"resetForm() requires a valid Angular Form object passed as argument to work properly (ex.: $scope.form1).";var l=a.commonObj.getFormElements(e.$name);if(l instanceof Array)for(var r=0,d=l.length;d>r;r++)t=l[r],i&&t.elm.val(null),n?m(e,{self:a,formElmObj:t}):("function"==typeof t.ctrl.$setUntouched&&t.ctrl.$setUntouched(),t.ctrl.$setPristine(),a.commonObj.updateErrorMsg("",{isValid:!1,obj:t}))}function d(e){var o=this,t="boolean"==typeof e?e:!0;o.commonObj.setDisplayOnlyLastErrorMsg(t)}function c(e){var o=this;return o.validationAttrs=e,o.commonObj.setGlobalOptions(e),o}function s(e,a,n){var i=o.defer(),l=!1,m="undefined"!=typeof n?n:e.commonObj.typingLimit,r=e.commonObj.getFormElementByName(e.commonObj.ctrl.$name);return a&&a.badInput?v(e,attrs.name):(e.commonObj.validate(a,!1),e.commonObj.isFieldRequired()||g||""!==a&&null!==a&&"undefined"!=typeof a?(r.isValidationCancelled=!1,(a||e.commonObj.isFieldRequired()||g)&&e.commonObj.ctrl.$setValidity("validation",!1),""!==a&&"undefined"!=typeof a||"NUMBER"!==e.commonObj.elm.prop("type").toUpperCase()?"SELECT"===e.commonObj.elm.prop("tagName").toUpperCase()?(l=e.commonObj.validate(a,!0),e.commonObj.ctrl.$setValidity("validation",l),i.resolve({isFieldValid:l,formElmObj:r,value:a}),i.promise):("undefined"!=typeof a&&(0===n?(l=e.commonObj.validate(a,!0),e.commonObj.scope.$evalAsync(e.commonObj.ctrl.$setValidity("validation",l)),i.resolve({isFieldValid:l,formElmObj:r,value:a}),t.cancel(e.timer)):(e.commonObj.updateErrorMsg(""),t.cancel(e.timer),e.timer=t(function(){l=e.commonObj.validate(a,!0),e.commonObj.scope.$evalAsync(e.commonObj.ctrl.$setValidity("validation",l)),i.resolve({isFieldValid:l,formElmObj:r,value:a})},m))),i.promise):(t.cancel(e.timer),l=e.commonObj.validate(a,!0),i.resolve({isFieldValid:l,formElmObj:r,value:a}),i.promise)):(u(e,r),i.resolve({isFieldValid:!0,formElmObj:r,value:a}),i.promise))}function u(e,o){var a=o&&o.ctrl?o.ctrl:e.commonObj.ctrl;o&&(o.isValidationCancelled=!0),t.cancel(self.timer),a.$setValidity("validation",!0),e.commonObj.updateErrorMsg("",{isValid:!0,obj:o}),y(e,o)}function f(e,o,a){return e.$watch(function(){return o.ctrl=angular.element(o.elm).controller("ngModel"),p(a,o.elmName)?{badInput:!0}:o.ctrl.$modelValue},function(n,i){if(n&&n.badInput){var l=a.commonObj.getFormElementByName(o.elmName);return y(a,l),v(a,o.name)}if(void 0===n&&void 0!==i&&!isNaN(i))return t.cancel(a.timer),void a.commonObj.ctrl.$setValidity("validation",a.commonObj.validate("",!0));o.ctrl=angular.element(o.elm).controller("ngModel"),o.value=n,a.commonObj.initialize(e,o.elm,o,o.ctrl);var m="undefined"==typeof n||"number"==typeof n&&isNaN(n)?0:void 0,r=s(a,n,m);$&&a.commonObj.runValidationCallbackOnPromise(r,$)},!0)}function v(e,o){t.cancel(e.timer);var a=e.commonObj.getFormElementByName(o);e.commonObj.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0,obj:a}),e.commonObj.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function p(e,o){var t=e.commonObj.getFormElementByName(o);return!!t&&!!t.elm.prop("validity")&&t.elm.prop("validity").badInput===!0}function b(e,o,t){var a=e.commonObj.scope?e.commonObj.scope:o.scope?o.scope:null;if("undefined"==typeof a)throw"removeValidator() requires a valid $scope object passed but unfortunately could not find it.";var n=e.commonObj.arrayFindObject(h,"elmName",o.fieldName);n&&(n.watcherHandler(),h.shift()),o.isValidationCancelled=!0,o.isValid=!0,o.attrs.validation="",u(e,o),"function"==typeof o.ctrl.$setUntouched&&o.ctrl.$setUntouched(),e.commonObj.scope=a,o.ctrl.$setPristine(),e.commonObj.removeFromValidationSummary(o.fieldName,t)}function y(e,o){if(o.isValidationCancelled=!0,"function"==typeof j){var t=o&&o.elm?o.elm:e.commonObj.elm;t.unbind("blur",j)}}function O(e,o,a){o.$watch(function(){return"undefined"==typeof a.elm.attr("ng-disabled")?null:o.$eval(a.elm.attr("ng-disabled"))},function(n){if("undefined"==typeof n||null===n)return null;a.ctrl=angular.element(a.elm).controller("ngModel"),e.commonObj.initialize(o,a.elm,a,a.ctrl);var i=e.commonObj.getFormElementByName(a.name);t(function(){if(n)a.ctrl.$setValidity("validation",!0),e.commonObj.updateErrorMsg("",{isValid:!0,obj:i}),e.commonObj.removeFromValidationSummary(a.name);else{var t=a.ctrl.$viewValue||"";e.commonObj.initialize(o,a.elm,a,a.ctrl),a.ctrl.$setValidity("validation",e.commonObj.validate(t,!1)),i&&(i.isValidationCancelled=!1),a.elm.bind("blur",j=function(o){if(i&&!i.isValidationCancelled){var t=s(e,o.target.value,10);$&&e.commonObj.runValidationCallbackOnPromise(t,$)}})}},0,!1),n&&("function"==typeof a.ctrl.$setUntouched&&a.ctrl.$setUntouched(),a.ctrl.$setValidity("validation",!0),e.commonObj.removeFromValidationSummary(a.name))})}var j,g,$,V,h=[],E=function(e){this.isValidationCancelled=!1,this.timer=null,this.validationAttrs={},this.commonObj=new a,e&&this.setGlobalOptions(e),V=this.commonObj.getGlobalOptions()};return E.prototype.addValidator=n,E.prototype.checkFormValidity=i,E.prototype.removeValidator=m,E.prototype.resetForm=r,E.prototype.setDisplayOnlyLastErrorMsg=d,E.prototype.setGlobalOptions=c,E.prototype.clearInvalidValidatorsInSummary=l,E}]); \ No newline at end of file diff --git a/more-examples/ngModelOptionBlur/app.js b/more-examples/ngModelOptionBlur/app.js new file mode 100644 index 0000000..d7e75b9 --- /dev/null +++ b/more-examples/ngModelOptionBlur/app.js @@ -0,0 +1,36 @@ +'use strict'; + +var myApp = angular.module('myApp', ['ghiscoding.validation', 'pascalprecht.translate']); +// -- +// configuration +myApp.config(['$compileProvider', function ($compileProvider) { + $compileProvider.debugInfoEnabled(false); + }]) + .config(['$translateProvider', function ($translateProvider) { + $translateProvider.useStaticFilesLoader({ + prefix: '../../locales/validation/', + suffix: '.json' + }); + // load English ('en') table on startup + $translateProvider.preferredLanguage('en').fallbackLanguage('en'); + $translateProvider.useSanitizeValueStrategy('escapeParameters'); + }]); + +// -- +// Directive +myApp.controller('CtrlDirective', ['ValidationService', function (ValidationService) { + var vmd = this; + vmd.model = {}; + + // use the ValidationService only to declare the controllerAs syntax + var vs = new ValidationService({ controllerAs: vmd }); + + vmd.input6 = "initialInput6"; + vmd.mylocation = { Name: "initialName", Name2: "initialName", Simple: "initialName" }; + + vmd.submitForm = function() { + if(vs.checkFormValidity(vmd.form1)) { + alert('All good, proceed with submit...'); + } + } +}]); diff --git a/more-examples/ngModelOptionBlur/index.html b/more-examples/ngModelOptionBlur/index.html new file mode 100644 index 0000000..cae2e4a --- /dev/null +++ b/more-examples/ngModelOptionBlur/index.html @@ -0,0 +1,85 @@ + + + + + Angular-Validation with Custom Javascript function + + + + + +
+

Example of Angular-Validation with Custom Javascript function

+ +
+
+
+
+ +
+ + +
+
+ + +
+
+

Control below NOT in a form, doesn't have problem

+ +
+ + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/package.json b/package.json index 419fbdc..50f695c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.1", + "version": "1.5.2", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": "app.js", diff --git a/readme.md b/readme.md index bbf28be..1bb2c43 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ #Angular Validation (Directive / Service) -`Version: 1.5.1` +`Version: 1.5.2` ### Forms Validation with Angular made easy! ##### (Concept comes from the amazing Laravel) diff --git a/src/validation-common.js b/src/validation-common.js index 6ab6276..40b5f30 100644 --- a/src/validation-common.js +++ b/src/validation-common.js @@ -235,11 +235,20 @@ angular // loop through all validators of the element for (var i = 0, ln = validations.length; i < ln; i++) { - // params split will be:: [0]=rule, [1]=ruleExtraParams OR altText, [2] altText - var params = validations[i].split(':'); - // check if user provided an alternate text to his validator (validator:alt=Alternate Text) - var hasAltText = validations[i].indexOf("alt=") >= 0; + var posAltText = validations[i].indexOf("alt="); + var hasAltText = posAltText >= 0; + var params = []; + + // alternate text might have the character ":" inside it, so we need to compensate + // since altText is always at the end, we can before the altText and add back this untouched altText to our params array + if(hasAltText) { + params = validations[i].substring(0,posAltText-1).split(':'); // split before altText, so we won't touch it + params.push(validations[i].substring(posAltText)); // add back the altText to our split params array + }else { + // params split will be:: [0]=rule, [1]=ruleExtraParams OR altText, [2] altText + params = validations[i].split(':'); + } self.validators[i] = ValidationRules.getElementValidators({ altText: hasAltText === true ? (params.length === 2 ? params[1] : params[2]) : '', From fe37eba1b5d3023abb8f49e29096141a54a789cf Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Tue, 14 Jun 2016 23:32:17 -0400 Subject: [PATCH 02/60] changelog --- changelog.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 5dd5690..ec0ff62 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,8 @@ Angular-Validation change logs -1.5.0 (2016-02-23) BREAKING CHANGE when fixing casing issue #107, ValidationService should start with uppercase. Changed to branch 1.5.x to announce major change. +1.5.2 (2016-06-14) Fixed #121 Alternate text containing the char ":" was causing unexpected displayed message. +1.5.1 (2016-03-10) Fixed #111 Add US phone number & tweaked credit card rules. +1.5.0 (2016-03-10) BREAKING CHANGE when fixing casing issue #107, ValidationService should start with uppercase. Changed to branch 1.5.x to announce major change. 1.4.22 (2016-02-02) Merged pull request #106 to add Catalan translation locale and some fixes in the Spanish locale as well. 1.4.21 (2016-01-21) Merged pull request #103 (extend Directive for revalidating) to fix request #102... thanks @tpeter1985. 1.4.20 (2016-01-17) Enhancement #100 - Add Global Option (errorMessageSeparator) for a Separator between error messages. Enhancement #101 - Add Global Option (preValidateValidationSummary) to disable pre-validation in Validation Summary if need be. Also found and fixed a problem with a try-catch throw javascript error in Custom Validation. From f50b6f39308f4df952cd3d6fa92e060a8833cf53 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Tue, 14 Jun 2016 23:51:57 -0400 Subject: [PATCH 03/60] typo --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 1bb2c43..24e79d6 100644 --- a/readme.md +++ b/readme.md @@ -18,7 +18,7 @@ Huge rewrite to have a better code separation and also adding support to Service For more reasons to use it, see the answered question of: [Why Use It?](#whyuseit) -If you like the Angular-Validation project and you use it, please click on the **Star** and add it as a favorite. The more star ratings there is, the more chances it could be found by other users inside the popular trend section. That is the only support I ask you... thanks and enjoy it ;) +If you like the Angular-Validation project and you use it, please click on the :star: and add it as a favorite. The more star ratings there is, the more chances it could be found by other users inside the popular trend section. That is the only support I ask you... thanks and enjoy it ;) ## Live Demo @@ -55,7 +55,7 @@ into the following (errors will automatically be displayed in your chosen locale ``` -The Angular-Validation will create, by itself, the necessary error message. Now imagine your form having 10 inputs, using the documented Angular way will end up being 30 lines of code, while on the other hand `Angular-Validation` will stay with 10 lines of code, no more... so what are you waiting for? Use Angular-Validation!!! Don't forget to add it to your favorite, click on the **Star** on top :) +The Angular-Validation will create, by itself, the necessary error message. Now imagine your form having 10 inputs, using the documented Angular way will end up being 30 lines of code, while on the other hand `Angular-Validation` will stay with 10 lines of code, no more... so what are you waiting for? Use Angular-Validation!!! Don't forget to add it to your favorite, click on the :star: on top :) Let's not forget the [Validation Summary](https://github.com/ghiscoding/angular-validation/wiki/Validation-Summary) which is also a great and useful way of displaying your errors to the user. From 7389b4dadf18ae6743018658f4af9ec059d421d7 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Wed, 20 Jul 2016 22:43:46 -0400 Subject: [PATCH 04/60] Added C# validation annotation Add more aliases for a few validators to fit the ones in C# validation annotation. --- bower.json | 2 +- changelog.txt | 1 + dist/angular-validation.min.js | 10 ++-- more-examples/addon-3rdParty/app.js | 11 +++++ more-examples/addon-3rdParty/index.html | 4 +- package.json | 2 +- readme.md | 62 ++++++++++++++----------- src/validation-rules.js | 13 ++++++ 8 files changed, 69 insertions(+), 36 deletions(-) diff --git a/bower.json b/bower.json index a235b83..01ff7ff 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.2", + "version": "1.5.3", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index ec0ff62..a099d71 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.3 (2016-07-20) Add C# validation annotation, (for example: maxLen => maxLength) 1.5.2 (2016-06-14) Fixed #121 Alternate text containing the char ":" was causing unexpected displayed message. 1.5.1 (2016-03-10) Fixed #111 Add US phone number & tweaked credit card rules. 1.5.0 (2016-03-10) BREAKING CHANGE when fixing casing issue #107, ValidationService should start with uppercase. Changed to branch 1.5.x to announce major change. diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 266c441..bd0ac2a 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.5.2 + * @version: 1.5.3 * @license: MIT - * @build: Tue Jun 14 2016 23:09:36 GMT-0400 (Eastern Daylight Time) + * @build: Wed Jul 20 2016 21:43:21 GMT-0400 (Eastern Daylight Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,l,r){function o(i,l){var o=a.defer(),d=!1,m="undefined"!=typeof l?l:$.typingLimit,s=$.getFormElementByName(r.$name);if(Array.isArray(i)){if(O=[],E="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||w||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||w)&&r.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),r.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===l?(d=$.validate(i,!0),n.$evalAsync(r.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(r.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(C){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){E.length>0&&g.displayOnlyLastErrorMsg?E="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):E+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(E,{isValid:!1}),$.addToValidationSummary(a.formElmObj,E)});break;case"one":default:a.isFieldValid===!0&&(r.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(r.$name),i="undefined"!=typeof r.$modelValue?r.$modelValue:a.target.value;if(e.isValidationCancelled)r.$setValidity("validation",!0);else{var n=o(i,0);F&&$.runValidationCallbackOnPromise(n,F)}}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var l in t)if(t.hasOwnProperty(l)){if(A&&l!==A)continue;d(t[l],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(h,"elmName",r.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();h.shift()}}function f(){var a=$.getFormElementByName(r.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),r.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){return y()?{badInput:!0}:r.$modelValue},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);F&&$.runValidationCallbackOnPromise(i,F)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(r.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=r.$modelValue||"";Array.isArray(a)||r.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(r.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,l,r),E="",O=[],h=[],g=$.getGlobalOptions(),j=l.name,F=l.hasOwnProperty("validationCallback")?l.validationCallback:null,w=l.hasOwnProperty("validateOnEmpty")?$.parseBool(l.validateOnEmpty):!!g.validateOnEmpty,C=l.hasOwnProperty("validArrayRequireHowMany")?l.validArrayRequireHowMany:"one",A=l.hasOwnProperty("validationArrayObjprop")?l.validationArrayObjprop:null;h.push({elmName:j,watcherHandler:v()}),l.$observe("disabled",function(a){a?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(h,"elmName",r.$name);e||h.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==r.$name){r.revalidateCalled=!0;var i=r.$modelValue;if(t.isValidationCancelled)r.$setValidity("validation",!0);else{var n=o(i);F&&$.runValidationCallbackOnPromise(n,F)}}})}}}]); -angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function i(e,t,r){if("undefined"!=typeof e&&null!=e){var i=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),n=E(i,e),o=w(z,"field",i);if(o>=0&&""===t)z.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:i,friendlyName:s,message:t,formName:n?n.$name:null};o>=0?z[o]=l:z.push(l)}if(e.scope.$validationSummary=z,n&&(n.$validationSummary=A(z,"formName",n.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,n&&n.$name)){var d=n.$name.indexOf(".")>=0?n.$name.split(".")[1]:n.$name,u=_.controllerAs[d]?_.controllerAs[d]:e.elm.controller()[d];u&&(u.$validationSummary=A(z,"formName",n.$name))}return z}}function n(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var i=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!i||i.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var n=i[1],o=i[2]?i[2].replace(/\|(.*)/,""):"",s=n.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+n,"pattern")}else if(a.indexOf("regex:")>=0){var i=a.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 d=i[1].split(":=");t={message:d[0],pattern:d[1]},a=a.replace(i[0],"regex:")}var u=a.split("|");if(u){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=u.length;m>p;p++){var c=u[p].indexOf("alt="),f=c>=0,g=[];f?(g=u[p].substring(0,c-1).split(":"),g.push(u[p].substring(c))):g=u[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return V(B,"fieldName",e)}function s(e){return e?A(B,"formName",e):B}function l(){return _}function d(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,O(t,a,r,e),this.defineValidation()}function u(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=w(B,"fieldName",e);t>=0&&B.splice(t,1)}function c(e,t){var a=this,r=E(e,a),i=t||z,n=w(i,"field",e);if(n>=0&&i.splice(n,1),n=w(z,"field",e),n>=0&&z.splice(n,1),a.scope.$validationSummary=z,r&&(r.$validationSummary=A(z,"formName",r.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;_.controllerAs[o]&&(_.controllerAs[o].$validationSummary=A(z,"formName",r.$name))}return z}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){_.displayOnlyLastErrorMsg=e}function y(e){var t=this;return _=p(_,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var i=t&&t.elm?t.elm:r.elm,n=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof n||null===n){var o=i?i.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=n.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),d=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var u=r.validatorAttrs.validationErrorTo.charAt(0),p="."===u||"#"===u?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;d=angular.element(document.querySelector(p))}d&&0!==d.length||(d=angular.element(document.querySelector(".validation-"+l)));var m=t&&t.isSubmitted?t.isSubmitted:!1;!_.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?d.length>0?d.html(s):i.after('
'+s+"
"):d.html("")}function b(e,t){var r,n=this,s=!0,l=!0,d=0,u={message:""};"undefined"==typeof e&&(e="");for(var p=n.ctrl&&n.ctrl.$name?n.ctrl.$name:n.attrs&&n.attrs.name?n.attrs.name:n.elm.attr("name"),m=o(p),c=n.validatorAttrs.rules||n.validatorAttrs.validation,f=0,g=n.validators.length;g>f;f++){r=n.validators[f],"autoDetect"===r.type&&(r=D(r,e));var v=n.attrs?n.attrs.ngDisabled:n.validatorAttrs.ngDisabled;switch(r.type){case"conditionalDate":s=C(e,r,c);break;case"conditionalNumber":s=U(e,r);break;case"javascript":s=j(e,r,n,m,t,u);break;case"matching":s=G(e,r,n,u);break;case"remote":s=H(e,r,n,m,t,u);break;default:s=P(e,r,c,n)}if((!n.bFieldRequired&&!e&&!K||n.elm.prop("disabled")||n.scope.$eval(v))&&(s=!0),s||(l=!1,function(e,r,i){var o=i.message,s=_.errorMessageSeparator||" ";i.altText&&i.altText.length>0&&(o=i.altText.replace("alt=",""));var d=a(o);e.translatePromise=d,e.validator=i,d.then(function(a){u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+(i&&i.params?String.format(a,i.params):a):u.message+=s+(i&&i.params?String.format(a,i.params):a),$(n,e,u.message,l,t)})["catch"](function(a){i.altText&&i.altText.length>0&&(u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+o:u.message+=s+o,$(n,e,u.message,l,t))})}(m,s,r)),s&&d++,n.validRequireHowMany==d&&s){l=!0;break}}return s&&(i(n,""),n.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function O(e,t,r,i){var n=t.name?t.name:e.attr("name"),o=E(n,{scope:i}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:n,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:i,isValid:!1,message:"",formName:o?o.$name:null},d=w(B,"fieldName",e.attr("name"));return d>=0?B[d]=l:B.push(l),B}function $(e,t,a,r,n){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(_.preValidateValidationSummary||"undefined"==typeof _.preValidateValidationSummary||n)&&i(t,a),(e.validatorAttrs.preValidateFormElements||_.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),n&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&i(t,"")}function S(e){return e.typingLimit=I,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):_&&_.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(_.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:_.validRequireHowMany,K=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):_.validateOnEmpty,e}function V(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(n){var o=n?n.getAttribute("name"):null;if(o){var s={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(_&&_.controllerAs&&o.indexOf(".")>=0){var l=o.split(".");return t.scope[l[0]][l[1]]=s}return t.scope[o]=s}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,i=0,n=r.length;n>i;i++)e[r[i]]&&(e=e[r[i]]);return e}function N(e){return"boolean"==typeof e||"number"==typeof e?e===!0||1===e:"string"==typeof e&&(e=e.replace(/^\s+|\s+$/g,"").toLowerCase(),"true"===e||"1"===e||"false"===e||"0"===e)?"true"===e||"1"===e:void 0}function T(e,t){var a="",r="-",i=[],n=[],o="",s="",l="";switch(t.toUpperCase()){case"EURO_LONG":case"EURO-LONG":a=e.substring(0,10),r=e.substring(2,3),i=q(a,r),l=i[0],s=i[1],o=i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),l=i[0],s=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),i=q(a,r),o=i[0],s=i[1],l=i[2],n=e.length>10?e.substring(11).split(":"):null}var d=n&&3===n.length?n[0]:0,u=n&&3===n.length?n[1]:0,p=n&&3===n.length?n[2]:0;return new Date(o,s-1,l,d,u,p)}function q(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function F(e,t,a){var r=!1;switch(e){case"<":r=a>t;break;case"<=":r=a>=t;break;case">":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function k(){return this.replace(/^\s+|\s+$/g,"")}function L(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function M(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function C(e,t,a){var r=!0,i=r=!1;if(e instanceof Date)i=!0;else{var n=new RegExp(t.pattern,t.patternFlag);i=(!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e?!1:n.test(e)}if(i){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),d=T(t.params[1],o).getTime(),u=F(t.condition[0],s,l),p=F(t.condition[1],s,d);r=u&&p}else{var m=T(t.params[0],o).getTime();r=F(t.condition,s,m)}}return r}function U(e,t){var a=!0;if(2==t.params.length){var r=F(t.condition[0],parseFloat(e),parseFloat(t.params[0])),i=F(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&i}else a=F(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function j(e,a,r,i,n,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",d="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||K){var u=a.params[0],p=f(r,u);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw d;s=!!p.isValid}if(s===!1?(i.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;$(r,i,e,!1,n)})):s===!0&&(i.isValid=!0,$(r,i,"",!0,n)),"undefined"==typeof p)throw d}return s}function G(e,t,r,i){var n=!0,s=t.params[0],l=r.scope.$eval(s),d=angular.element(document.querySelector('[name="'+s+'"]')),u=t,p=r.ctrl,m=o(r.ctrl.$name);return n=F(t.condition,e,l)&&!!e,d&&d.attr("friendly-name")?t.params[1]=d.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var n=F(u.condition,p.$viewValue,e);if(e!==t){if(n)$(r,m,"",!0,!0);else{m.isValid=!1;var o=u.message;u.altText&&u.altText.length>0&&(o=u.altText.replace("alt=","")),a(o).then(function(e){var t=_.errorMessageSeparator||" ";i.message=t+(u&&u.params?String.format(e,u.params):e),$(r,m,i.message,n,!0)})}p.$setValidity("validation",n)}},!0),n}function H(e,t,a,r,i,n){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&i||K){a.ctrl.$processing=!0;var d=t.params[0],u=f(a,d);if(J.length>1)for(;J.length>0;){var p=J.pop();"function"==typeof p.abort&&p.abort()}if(J.push(u),!u||"function"!=typeof u.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){u.then(function(t){t=t.data||t,J.pop(),a.ctrl.$processing=!1;var d=n.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,d+=t.message||e," "===d)throw s;$(a,r,d,!1,i)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),$(a,r,"",!0,i))})}(t.altText)}return o}function P(e,t,a,r){var i=!0,n=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(n))i=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())i=!1;else{var o=new RegExp(t.pattern,t.patternFlag);i=(!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e?!1:o.test(e)}return i}function D(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var I=1e3,B=[],_={resetGlobalOptionsOnRouteChange:!0},J=[],z=[],K=!1;e.$on("$routeChangeStart",function(e,t,a){_.resetGlobalOptionsOnRouteChange&&(_={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},B=[],z=[])});var Y=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=I,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(_=e.$validationOptions),e&&(_.isolatedScope||_.scope)&&(this.scope=_.isolatedScope||_.scope,_=p(e.$validationOptions,_)),"undefined"==typeof _.resetGlobalOptionsOnRouteChange&&(_.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&(O(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return Y.prototype.addToValidationSummary=i,Y.prototype.arrayFindObject=V,Y.prototype.defineValidation=n,Y.prototype.getFormElementByName=o,Y.prototype.getFormElements=s,Y.prototype.getGlobalOptions=l,Y.prototype.isFieldRequired=u,Y.prototype.initialize=d,Y.prototype.mergeObjects=p,Y.prototype.parseBool=N,Y.prototype.removeFromValidationSummary=c,Y.prototype.removeFromFormElementObjectList=m,Y.prototype.runValidationCallbackOnPromise=g,Y.prototype.setDisplayOnlyLastErrorMsg=v,Y.prototype.setGlobalOptions=y,Y.prototype.updateErrorMsg=h,Y.prototype.validate=b,String.prototype.trim=k,String.prototype.format=L,String.format=M,Y}]); -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"accepted":n={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":n={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":n={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":n={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":n={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":n={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":n={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";n={patternLength:"^(.|[\\r\\n]){"+_[0]+","+_[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"autoDetect"};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:"^(.|[\\r\\n]){"+_[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"boolean":n={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":n={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":n={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":n={message:"",params:[r],type:"javascript"};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"different":case"differentInput":case"different_input":var e=r.split(",");n={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":n={pattern:"^\\d{"+r+"}$",message:"INVALID_DIGITS",params:[r],type:"regex"};break;case"digitsBetween":case"digits_between":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";n={pattern:"^\\d{"+_[0]+","+_[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[_[0],_[1]],type:"regex"};break;case"email":n={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":n={pattern:"^(.|[\\r\\n]){"+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}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"in":case"inList":case"in_list":var c=RegExp().escape(r).replace(/,/g,"|");n={pattern:"^("+c+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[r],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"ip":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:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"match":case"matchInput":case"match_input":case"same":var e=r.split(",");n={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":n={patternLength:"^(.|[\\r\\n]){0,"+r+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[r],type:"autoDetect"};break;case"maxLen":case"max_len":n={pattern:"^(.|[\\r\\n]){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"min":n={patternLength:"^(.|[\\r\\n]){"+r+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[r],type:"autoDetect"};break;case"minLen":case"min_len":n={pattern:"^(.|[\\r\\n]){"+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"notIn":case"not_in":case"notInList":case"not_in_list":var c=RegExp().escape(r).replace(/,/g,"|");n={pattern:"^((?!("+c+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[r],type:"regex"};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"phone":n={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"pattern":case"regex":n={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":n={message:"",params:[r],type:"remote"};break;case"required":n={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":n={patternLength:"^(.|[\\r\\n]){"+r+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[r],type:"autoDetect"};break;case"url":n={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,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}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; -angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e){var o=this,t="",a=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var n=0,i=e.$validationSummary.length;i>n;n++)if(a=!1,t=e.$validationSummary[n].field){var l=o.commonObj.getFormElementByName(t);l&&l.elm&&l.elm.length>0&&("function"==typeof l.ctrl.$setTouched&&l.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:l.isValid,obj:l}))}return a}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;n>a;a++)t.push(e.$validationSummary[a].field);for(a=0,n=t.length;n>a;a++)t[a]&&(o.commonObj.removeFromFormElementObjectList(t[a]),o.commonObj.removeFromValidationSummary(t[a],e.$validationSummary))}function m(e,o){var t,a=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"removeValidator() only works with Validation that were defined by the Service (not by the Directive) and requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";if(o instanceof Array)for(var n=0,i=o.length;i>n;n++)t=a.commonObj.getFormElementByName(o[n]),t.elm.removeAttr("validation"),b(a,t,e.$validationSummary);else o instanceof Object&&o.formElmObj?(t=o.formElmObj,t.elm.removeAttr("validation"),b(o.self,t,e.$validationSummary)):(t=a.commonObj.getFormElementByName(o),t.elm.removeAttr("validation"),b(a,t,e.$validationSummary));return a}function r(e,o){var t,a=this,o=o||{},n="undefined"!=typeof o.removeAllValidators?o.removeAllValidators:!1,i="undefined"!=typeof o.emptyAllInputValues?o.emptyAllInputValues:!1;if("undefined"==typeof e||"undefined"==typeof e.$name)throw"resetForm() requires a valid Angular Form object passed as argument to work properly (ex.: $scope.form1).";var l=a.commonObj.getFormElements(e.$name);if(l instanceof Array)for(var r=0,d=l.length;d>r;r++)t=l[r],i&&t.elm.val(null),n?m(e,{self:a,formElmObj:t}):("function"==typeof t.ctrl.$setUntouched&&t.ctrl.$setUntouched(),t.ctrl.$setPristine(),a.commonObj.updateErrorMsg("",{isValid:!1,obj:t}))}function d(e){var o=this,t="boolean"==typeof e?e:!0;o.commonObj.setDisplayOnlyLastErrorMsg(t)}function c(e){var o=this;return o.validationAttrs=e,o.commonObj.setGlobalOptions(e),o}function s(e,a,n){var i=o.defer(),l=!1,m="undefined"!=typeof n?n:e.commonObj.typingLimit,r=e.commonObj.getFormElementByName(e.commonObj.ctrl.$name);return a&&a.badInput?v(e,attrs.name):(e.commonObj.validate(a,!1),e.commonObj.isFieldRequired()||g||""!==a&&null!==a&&"undefined"!=typeof a?(r.isValidationCancelled=!1,(a||e.commonObj.isFieldRequired()||g)&&e.commonObj.ctrl.$setValidity("validation",!1),""!==a&&"undefined"!=typeof a||"NUMBER"!==e.commonObj.elm.prop("type").toUpperCase()?"SELECT"===e.commonObj.elm.prop("tagName").toUpperCase()?(l=e.commonObj.validate(a,!0),e.commonObj.ctrl.$setValidity("validation",l),i.resolve({isFieldValid:l,formElmObj:r,value:a}),i.promise):("undefined"!=typeof a&&(0===n?(l=e.commonObj.validate(a,!0),e.commonObj.scope.$evalAsync(e.commonObj.ctrl.$setValidity("validation",l)),i.resolve({isFieldValid:l,formElmObj:r,value:a}),t.cancel(e.timer)):(e.commonObj.updateErrorMsg(""),t.cancel(e.timer),e.timer=t(function(){l=e.commonObj.validate(a,!0),e.commonObj.scope.$evalAsync(e.commonObj.ctrl.$setValidity("validation",l)),i.resolve({isFieldValid:l,formElmObj:r,value:a})},m))),i.promise):(t.cancel(e.timer),l=e.commonObj.validate(a,!0),i.resolve({isFieldValid:l,formElmObj:r,value:a}),i.promise)):(u(e,r),i.resolve({isFieldValid:!0,formElmObj:r,value:a}),i.promise))}function u(e,o){var a=o&&o.ctrl?o.ctrl:e.commonObj.ctrl;o&&(o.isValidationCancelled=!0),t.cancel(self.timer),a.$setValidity("validation",!0),e.commonObj.updateErrorMsg("",{isValid:!0,obj:o}),y(e,o)}function f(e,o,a){return e.$watch(function(){return o.ctrl=angular.element(o.elm).controller("ngModel"),p(a,o.elmName)?{badInput:!0}:o.ctrl.$modelValue},function(n,i){if(n&&n.badInput){var l=a.commonObj.getFormElementByName(o.elmName);return y(a,l),v(a,o.name)}if(void 0===n&&void 0!==i&&!isNaN(i))return t.cancel(a.timer),void a.commonObj.ctrl.$setValidity("validation",a.commonObj.validate("",!0));o.ctrl=angular.element(o.elm).controller("ngModel"),o.value=n,a.commonObj.initialize(e,o.elm,o,o.ctrl);var m="undefined"==typeof n||"number"==typeof n&&isNaN(n)?0:void 0,r=s(a,n,m);$&&a.commonObj.runValidationCallbackOnPromise(r,$)},!0)}function v(e,o){t.cancel(e.timer);var a=e.commonObj.getFormElementByName(o);e.commonObj.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0,obj:a}),e.commonObj.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function p(e,o){var t=e.commonObj.getFormElementByName(o);return!!t&&!!t.elm.prop("validity")&&t.elm.prop("validity").badInput===!0}function b(e,o,t){var a=e.commonObj.scope?e.commonObj.scope:o.scope?o.scope:null;if("undefined"==typeof a)throw"removeValidator() requires a valid $scope object passed but unfortunately could not find it.";var n=e.commonObj.arrayFindObject(h,"elmName",o.fieldName);n&&(n.watcherHandler(),h.shift()),o.isValidationCancelled=!0,o.isValid=!0,o.attrs.validation="",u(e,o),"function"==typeof o.ctrl.$setUntouched&&o.ctrl.$setUntouched(),e.commonObj.scope=a,o.ctrl.$setPristine(),e.commonObj.removeFromValidationSummary(o.fieldName,t)}function y(e,o){if(o.isValidationCancelled=!0,"function"==typeof j){var t=o&&o.elm?o.elm:e.commonObj.elm;t.unbind("blur",j)}}function O(e,o,a){o.$watch(function(){return"undefined"==typeof a.elm.attr("ng-disabled")?null:o.$eval(a.elm.attr("ng-disabled"))},function(n){if("undefined"==typeof n||null===n)return null;a.ctrl=angular.element(a.elm).controller("ngModel"),e.commonObj.initialize(o,a.elm,a,a.ctrl);var i=e.commonObj.getFormElementByName(a.name);t(function(){if(n)a.ctrl.$setValidity("validation",!0),e.commonObj.updateErrorMsg("",{isValid:!0,obj:i}),e.commonObj.removeFromValidationSummary(a.name);else{var t=a.ctrl.$viewValue||"";e.commonObj.initialize(o,a.elm,a,a.ctrl),a.ctrl.$setValidity("validation",e.commonObj.validate(t,!1)),i&&(i.isValidationCancelled=!1),a.elm.bind("blur",j=function(o){if(i&&!i.isValidationCancelled){var t=s(e,o.target.value,10);$&&e.commonObj.runValidationCallbackOnPromise(t,$)}})}},0,!1),n&&("function"==typeof a.ctrl.$setUntouched&&a.ctrl.$setUntouched(),a.ctrl.$setValidity("validation",!0),e.commonObj.removeFromValidationSummary(a.name))})}var j,g,$,V,h=[],E=function(e){this.isValidationCancelled=!1,this.timer=null,this.validationAttrs={},this.commonObj=new a,e&&this.setGlobalOptions(e),V=this.commonObj.getGlobalOptions()};return E.prototype.addValidator=n,E.prototype.checkFormValidity=i,E.prototype.removeValidator=m,E.prototype.resetForm=r,E.prototype.setDisplayOnlyLastErrorMsg=d,E.prototype.setGlobalOptions=c,E.prototype.clearInvalidValidatorsInSummary=l,E}]); \ No newline at end of file +angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function i(e,t,r){if("undefined"!=typeof e&&null!=e){var i=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),n=E(i,e),o=w(z,"field",i);if(o>=0&&""===t)z.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:i,friendlyName:s,message:t,formName:n?n.$name:null};o>=0?z[o]=l:z.push(l)}if(e.scope.$validationSummary=z,n&&(n.$validationSummary=A(z,"formName",n.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,n&&n.$name)){var d=n.$name.indexOf(".")>=0?n.$name.split(".")[1]:n.$name,u=_.controllerAs[d]?_.controllerAs[d]:e.elm.controller()[d];u&&(u.$validationSummary=A(z,"formName",n.$name))}return z}}function n(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var i=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!i||i.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var n=i[1],o=i[2]?i[2].replace(/\|(.*)/,""):"",s=n.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+n,"pattern")}else if(a.indexOf("regex:")>=0){var i=a.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 d=i[1].split(":=");t={message:d[0],pattern:d[1]},a=a.replace(i[0],"regex:")}var u=a.split("|");if(u){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=u.length;p=0,g=[];f?(g=u[p].substring(0,c-1).split(":"),g.push(u[p].substring(c))):g=u[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return V(B,"fieldName",e)}function s(e){return e?A(B,"formName",e):B}function l(){return _}function d(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,O(t,a,r,e),this.defineValidation()}function u(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=w(B,"fieldName",e);t>=0&&B.splice(t,1)}function c(e,t){var a=this,r=E(e,a),i=t||z,n=w(i,"field",e);if(n>=0&&i.splice(n,1),n=w(z,"field",e),n>=0&&z.splice(n,1),a.scope.$validationSummary=z,r&&(r.$validationSummary=A(z,"formName",r.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;_.controllerAs[o]&&(_.controllerAs[o].$validationSummary=A(z,"formName",r.$name))}return z}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){_.displayOnlyLastErrorMsg=e}function y(e){var t=this;return _=p(_,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var i=t&&t.elm?t.elm:r.elm,n=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof n||null===n){var o=i?i.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=n.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),d=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var u=r.validatorAttrs.validationErrorTo.charAt(0),p="."===u||"#"===u?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;d=angular.element(document.querySelector(p))}d&&0!==d.length||(d=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!_.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?d.length>0?d.html(s):i.after('
'+s+"
"):d.html("")}function b(e,t){var r,n=this,s=!0,l=!0,d=0,u={message:""};"undefined"==typeof e&&(e="");for(var p=n.ctrl&&n.ctrl.$name?n.ctrl.$name:n.attrs&&n.attrs.name?n.attrs.name:n.elm.attr("name"),m=o(p),c=n.validatorAttrs.rules||n.validatorAttrs.validation,f=0,g=n.validators.length;f0&&(o=i.altText.replace("alt=",""));var d=a(o);e.translatePromise=d,e.validator=i,d.then(function(a){u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+(i&&i.params?String.format(a,i.params):a):u.message+=s+(i&&i.params?String.format(a,i.params):a),$(n,e,u.message,l,t)})["catch"](function(a){i.altText&&i.altText.length>0&&(u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+o:u.message+=s+o,$(n,e,u.message,l,t))})}(m,s,r)),s&&d++,n.validRequireHowMany==d&&s){l=!0;break}}return s&&(i(n,""),n.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function O(e,t,r,i){var n=t.name?t.name:e.attr("name"),o=E(n,{scope:i}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:n,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:i,isValid:!1,message:"",formName:o?o.$name:null},d=w(B,"fieldName",e.attr("name"));return d>=0?B[d]=l:B.push(l),B}function $(e,t,a,r,n){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(_.preValidateValidationSummary||"undefined"==typeof _.preValidateValidationSummary||n)&&i(t,a),(e.validatorAttrs.preValidateFormElements||_.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),n&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&i(t,"")}function S(e){return e.typingLimit=I,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):_&&_.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(_.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:_.validRequireHowMany,K=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):_.validateOnEmpty,e}function V(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(n){var o=n?n.getAttribute("name"):null;if(o){var s={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(_&&_.controllerAs&&o.indexOf(".")>=0){var l=o.split(".");return t.scope[l[0]][l[1]]=s}return t.scope[o]=s}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,i=0,n=r.length;i8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),l=i[0],s=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),i=q(a,r),o=i[0],s=i[1],l=i[2],n=e.length>10?e.substring(11).split(":"):null}var d=n&&3===n.length?n[0]:0,u=n&&3===n.length?n[1]:0,p=n&&3===n.length?n[2]:0;return new Date(o,s-1,l,d,u,p)}function q(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function F(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function k(){return this.replace(/^\s+|\s+$/g,"")}function L(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function M(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function C(e,t,a){var r=!0,i=r=!1;if(e instanceof Date)i=!0;else{var n=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&n.test(e)}if(i){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),d=T(t.params[1],o).getTime(),u=F(t.condition[0],s,l),p=F(t.condition[1],s,d);r=u&&p}else{var m=T(t.params[0],o).getTime();r=F(t.condition,s,m)}}return r}function U(e,t){var a=!0;if(2==t.params.length){var r=F(t.condition[0],parseFloat(e),parseFloat(t.params[0])),i=F(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&i}else a=F(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function j(e,a,r,i,n,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",d="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||K){var u=a.params[0],p=f(r,u);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw d;s=!!p.isValid}if(s===!1?(i.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;$(r,i,e,!1,n)})):s===!0&&(i.isValid=!0,$(r,i,"",!0,n)),"undefined"==typeof p)throw d}return s}function G(e,t,r,i){var n=!0,s=t.params[0],l=r.scope.$eval(s),d=angular.element(document.querySelector('[name="'+s+'"]')),u=t,p=r.ctrl,m=o(r.ctrl.$name);return n=F(t.condition,e,l)&&!!e,d&&d.attr("friendly-name")?t.params[1]=d.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var n=F(u.condition,p.$viewValue,e);if(e!==t){if(n)$(r,m,"",!0,!0);else{m.isValid=!1;var o=u.message;u.altText&&u.altText.length>0&&(o=u.altText.replace("alt=","")),a(o).then(function(e){var t=_.errorMessageSeparator||" ";i.message=t+(u&&u.params?String.format(e,u.params):e),$(r,m,i.message,n,!0)})}p.$setValidity("validation",n)}},!0),n}function H(e,t,a,r,i,n){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&i||K){a.ctrl.$processing=!0;var d=t.params[0],u=f(a,d);if(J.length>1)for(;J.length>0;){var p=J.pop();"function"==typeof p.abort&&p.abort()}if(J.push(u),!u||"function"!=typeof u.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){u.then(function(t){t=t.data||t,J.pop(),a.ctrl.$processing=!1;var d=n.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,d+=t.message||e," "===d)throw s;$(a,r,d,!1,i)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),$(a,r,"",!0,i))})}(t.altText)}return o}function P(e,t,a,r){var i=!0,n=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(n))i=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())i=!1;else{var o=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return i}function D(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var I=1e3,B=[],_={resetGlobalOptionsOnRouteChange:!0},J=[],z=[],K=!1;e.$on("$routeChangeStart",function(e,t,a){_.resetGlobalOptionsOnRouteChange&&(_={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},B=[],z=[])});var Y=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=I,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(_=e.$validationOptions),e&&(_.isolatedScope||_.scope)&&(this.scope=_.isolatedScope||_.scope,_=p(e.$validationOptions,_)),"undefined"==typeof _.resetGlobalOptionsOnRouteChange&&(_.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&(O(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return Y.prototype.addToValidationSummary=i,Y.prototype.arrayFindObject=V,Y.prototype.defineValidation=n,Y.prototype.getFormElementByName=o,Y.prototype.getFormElements=s,Y.prototype.getGlobalOptions=l,Y.prototype.isFieldRequired=u,Y.prototype.initialize=d,Y.prototype.mergeObjects=p,Y.prototype.parseBool=N,Y.prototype.removeFromValidationSummary=c,Y.prototype.removeFromFormElementObjectList=m,Y.prototype.runValidationCallbackOnPromise=g,Y.prototype.setDisplayOnlyLastErrorMsg=v,Y.prototype.setGlobalOptions=y,Y.prototype.updateErrorMsg=h,Y.prototype.validate=b,String.prototype.trim=k,String.prototype.format=L,String.format=M,Y}]); +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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,r={};switch(s){case"accepted":r={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";r={patternLength:"^(.|[\\r\\n]){"+_[0]+","+_[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";r={pattern:"^(.|[\\r\\n]){"+_[0]+","+_[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[_[0],_[1]],type:"regex"};break;case"betweenNum":case"between_num":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";r={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"conditionalNumber"};break;case"boolean":r={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":r={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":r={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":r={message:"",params:[n],type:"javascript"};break;case"dateEuroLong":case"date_euro_long":r={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 _=n.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";r={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":r={condition:"<=",dateType:"EURO_LONG",params:[n],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":r={condition:">=",dateType:"EURO_LONG",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"EURO_SHORT",params:[n],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":r={condition:">=",dateType:"EURO_SHORT",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"ISO",params:[n],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":r={condition:">=",dateType:"ISO",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"US_LONG",params:[n],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":r={condition:">=",dateType:"US_LONG",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"US_SHORT",params:[n],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":r={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");r={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":r={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";r={pattern:"^\\d{"+_[0]+","+_[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[_[0],_[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":r={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":r={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":r={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":r={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":r={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var c=RegExp().escape(n).replace(/,/g,"|");r={pattern:"^("+c+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":r={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":r={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":r={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":r={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");r={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":r={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":r={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":r={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":r={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":r={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":r={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var c=RegExp().escape(n).replace(/,/g,"|");r={pattern:"^((?!("+c+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":r={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":r={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":r={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"pattern":case"regex":r={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":r={message:"",params:[n],type:"remote"};break;case"required":r={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":r={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":r={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":r={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return r.altText=a,r}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; +angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e){var o=this,t="",a=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var n=0,i=e.$validationSummary.length;n0&&("function"==typeof l.ctrl.$setTouched&&l.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:l.isValid,obj:l}))}return a}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a" }, { name: "Chrome", maker: "Google", ticked: false, icon: "" } ]; + + // declare public functions + vm.submit = submit; + + return vm; + + function submit() { + if(new ValidationService().checkFormValidity(vm.test)) { + alert('valid'); + } + } }]); diff --git a/more-examples/addon-3rdParty/index.html b/more-examples/addon-3rdParty/index.html index a6c43dc..47c28b8 100644 --- a/more-examples/addon-3rdParty/index.html +++ b/more-examples/addon-3rdParty/index.html @@ -91,14 +91,14 @@

ERRORS!


- +

We can validate an input array by 2 ways:
    -
  1. <valid-array-require-how-many="one"> (default), if 1 value is found good, the complete input set is Valid.
  2. +
  3. <valid-array-require-how-many="one"> (default), if 1 value is found as valid, the complete input set is Valid.
  4. <valid-array-require-how-many="all">. For the input to be Valid, we need "all" array values to be valid.
diff --git a/package.json b/package.json index 50f695c..600c23b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.2", + "version": "1.5.3", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": "app.js", diff --git a/readme.md b/readme.md index 24e79d6..2659d11 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ #Angular Validation (Directive / Service) -`Version: 1.5.2` +`Version: 1.5.3` ### Forms Validation with Angular made easy! ##### (Concept comes from the amazing Laravel) @@ -144,16 +144,17 @@ All validators are written as `snake_case` but it's up to the user's taste and c * `alpha_num_spaces` Only alpha-numeric characters (with latin & spaces) are present (a-z, A-Z, 0-9) * `alpha_dash` Only alpha-numeric characters + dashes, underscores are present (a-z, A-Z, 0-9, _-) * `alpha_dash_spaces` Alpha-numeric chars + dashes, underscores and spaces (a-z, A-Z, 0-9, _-) -* `between:min,max` will auto-detect value type then use proper validator. +* `between:min,max` Will auto-detect value type then use proper validator. * Type Number uses `between_num`, String use `between_len`. -* `between_date_iso:d1,d2` alias of `between_date_iso`. -* `between_date_euro_long:d1,d2` alias of `date_euro_long_between`. -* `between_date_euro_short:d1,d2` alias of `date_euro_short_between`. -* `between_date_us_long:d1,d2` alias of `date_us_long_between`. -* `between_date_us_short:d1,d2` alias of `date_us_short_between`. +* `between_date_iso:d1,d2` Alias of `between_date_iso`. +* `between_date_euro_long:d1,d2` Alias of `date_euro_long_between`. +* `between_date_euro_short:d1,d2` Alias of `date_euro_short_between`. +* `between_date_us_long:d1,d2` Alias of `date_us_long_between`. +* `between_date_us_short:d1,d2` Alias of `date_us_short_between`. * `between_len:min,max` Ensures the length of a string is between a min,max length. * `between_num:min,max` Ensures the numeric value (int or float) is between a min,max number. * `boolean` Ensures the value is `true` or `false` (`0` or `1` is also valid). +* `compare` Alias of `match` * `credit_card` Valid credit card number (AMEX, VISA, Mastercard, Diner's Club, Discover, JCB) * `date_iso` Ensure date follows the ISO format (yyyy-mm-dd) * `date_iso_between:d1,d2` Ensure date follows the ISO format and is between (d1) & (d2) @@ -175,55 +176,62 @@ All validators are written as `snake_case` but it's up to the user's taste and c * `date_us_short_between:d1,d2` Date must follow the US short format and is between (d1) & (d2) * `date_us_short_max:d` Date must follow US short format and is lower or equal than date (d) * `date_us_short_min:d` Date must follow US short format and is higher or equal than date (d) -* `different` alias of `different_input` +* `different` Alias of `different_input` * `different_input:f` Must be different from another input field(f), where (f) must be the exact ngModel attribute of input field to compare to. The error message will use the input name or the `friendly-name` if it was provided on first input, ex.: `` will display :: *Field must be different from specified field "First Name"*. * `different_input:f,t` Must be different from another input field(f), same as (different:f) but also include (t) for alternate input name to be displayed in the error message (it still uses a generic error message, if you really wish to replace the full error message then you should use `match:n:alt` see [:alt](https://github.com/ghiscoding/angular-validation/wiki/Alternate-Text-on-Validators)) * `digits:n` Ensures that field only has integer numbers and length precisely matches the specified length (n). * `digits_between:min,max` Ensures that field only has integer numbers and is between a min,max length. * `email` Checks for a valid email address +* `email_address` Alias of `email` +* `enum` Alias of `in_list` * `exact_len:n` Ensures that field length precisely matches the specified length (n). * `float` as to be floating value (excluding integer) * `float_signed` Has to be floating value (excluding int), could be signed (-/+) positive/negative. * ~~`iban`~~ To properly validate an IBAN please use [Wiki - Custom Validation](https://github.com/ghiscoding/angular-validation/wiki/Custom-Validation-functions) with an external library like [Github arhs/iban.js](https://github.com/arhs/iban.js) -* `in` alias of `in_list` +* `in` Alias of `in_list` * `in_list:foo,bar,..` Ensures the value is included inside the given list of values. The list must be separated by ',' and also accept words with spaces for example "ice cream". * `int` Only positive integer (alias to `integer`). * `integer` Only positive integer. * `int_signed` Only integer, could be signed (-/+) positive/negative (alias to `integer_signed`). * `integer_signed` Only integer, could be signed (-/+) positive/negative. -* `ip` alias of `ipv4` +* `ip` Alias of `ipv4` * `ipv4` Check for valid IP (IPv4) * `ipv6` Check for valid IP (IPv6) * `match:f` Match another input field(f), where (f) must be the exact ngModel attribute of input field to compare to. The error message will use the `friendly-name` if it was provided on first input, ex.: `` will display :: *Confirmation field does not match specified field "Password"*. * `match:f,t` Match another input field(f), same as (match:f) but also include (t) for alternate input name to be displayed in the error message (it still uses a generic error message, if you really wish to replace the full error message then you should use `match:n:alt` see [:alt](https://github.com/ghiscoding/angular-validation/wiki/Alternate-Text-on-Validators)) -* `match_input` alias of `match`. -* `max:n` will auto-detect value type then use proper validator. +* `match_input` Alias of `match`. +* `max:n` Will auto-detect value type then use proper validator. * Type Number uses `max_num`, String use `max_len`. -* `max_date_iso` alias of `date_iso_max`. -* `max_date_euro_long` alias of `date_euro_long_max`. -* `max_date_euro_short` alias of `date_euro_short_max`. -* `max_date_us_long` alias of `date_us_long_max`. -* `max_date_us_short` alias of `date_us_short_max`. +* `max_date_iso` Alias of `date_iso_max`. +* `max_date_euro_long` Alias of `date_euro_long_max`. +* `max_date_euro_short` Alias of `date_euro_short_max`. +* `max_date_us_long` Alias of `date_us_long_max`. +* `max_date_us_short` Alias of `date_us_short_max`. * `max_len:n` Checks field length, no longer than specified length where (n) is length parameter. +* `max_length:n` Alias of `max_len` * `max_num:n` Checks numeric value to be lower or equal than the number (n). -* `min:n` will auto-detect value type then use proper validator. +* `min:n` Will auto-detect value type then use proper validator. * Type Number uses `min_num`, String use `min_len`. -* `min_date_iso` alias of `date_iso_min`. -* `min_date_euro_long` alias of `date_euro_long_min`. -* `min_date_euro_short` alias of `date_euro_short_min`. -* `min_date_us_long` alias of `date_us_long_min`. -* `min_date_us_short` alias of `date_us_short_min`. +* `min_date_iso` Alias of `date_iso_min`. +* `min_date_euro_long` Alias of `date_euro_long_min`. +* `min_date_euro_short` Alias of `date_euro_short_min`. +* `min_date_us_long` Alias of `date_us_long_min`. +* `min_date_us_short` Alias of `date_us_short_min`. * `min_len:n` Checks field length, no shorter than specified length where (n) is length parameter. +* `min_length:n` Alias of `min_len` * `min_num:n` Checks numeric value to be higher or equal than the number (n). -* `not_in` alias of `not_in_list` +* `not_in` Alias of `not_in_list` * `not_in_list:foo,bar,..` Ensures the value is included inside the given list of values. The list must be separated by ',' and also accept words with spaces for example "ice cream". * `numeric` Only positive numeric value (float, integer). * `numeric_signed` Only numeric value (float, integer) can also be signed (-/+). -* `pattern` Ensure it follows a regular expression pattern... please see [Regular Expression Pattern](https://github.com/ghiscoding/angular-validation/wiki/Regular-Expression-Pattern) +* `pattern` Ensure it follows a regular expression pattern... Refer to [Wiki - Regular Expression Pattern](https://github.com/ghiscoding/angular-validation/wiki/Regular-Expression-Pattern) on how to use it. +* `range` Alias of `between` * `required` Ensures the specified key value exists and is not empty -* `same` alias of `match`. -* `size` will auto-detect value type then use proper validator. +* `same` Alias of `match`. +* `size` Will auto-detect value type then use proper validator. * Type Number uses `exact_num`, String use `exact_len`. +* `string_len` Alias of `between_len` +* `string_length` Alias of `between_len` * `time` Ensure time follows the format of (hh:mm) or (hh:mm:ss) * `url` Check for valid URL or subdomain \ No newline at end of file diff --git a/src/validation-rules.js b/src/validation-rules.js index d742282..65a4395 100644 --- a/src/validation-rules.js +++ b/src/validation-rules.js @@ -92,6 +92,7 @@ angular }; break; case "between" : + case "range" : var ranges = ruleParams.split(','); if (ranges.length !== 2) { throw "This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5"; @@ -107,6 +108,10 @@ angular break; case "betweenLen" : case "between_len" : + case "stringLen" : + case "string_len" : + case "stringLength" : + case "string_length" : var ranges = ruleParams.split(','); if (ranges.length !== 2) { throw "This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5"; @@ -449,6 +454,8 @@ angular }; break; case "email" : + case "emailAddress" : + case "email_address" : validator = { // Email RFC 5322, pattern pulled from http://www.regular-expressions.info/email.html // but removed necessity of a TLD (Top Level Domain) which makes this email valid: admin@mailserver1 @@ -488,6 +495,7 @@ angular type: "regex" }; break; + case "enum" : case "in" : case "inList" : case "in_list" : @@ -533,6 +541,7 @@ angular type: "regex" }; break; + case "compare" : case "match" : case "matchInput" : case "match_input" : @@ -557,6 +566,8 @@ angular break; case "maxLen" : case "max_len" : + case "maxLength" : + case "max_length" : validator = { pattern: "^(.|[\\r\\n]){0," + ruleParams + "}$", message: "INVALID_MAX_CHAR", @@ -585,6 +596,8 @@ angular break; case "minLen" : case "min_len" : + case "minLength" : + case "min_length" : validator = { pattern: "^(.|[\\r\\n]){" + ruleParams + ",}$", message: "INVALID_MIN_CHAR", From 5696c3ad26dd42f40943da0f14a03e13e1f1f1c9 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Fri, 29 Jul 2016 01:22:12 -0400 Subject: [PATCH 05/60] Fixed an issue with 3rd party single object - Fixed an issue with 3rd validation when an object was disguised as an array and was not triggering a $scope.$watch, so the validation was never kicking in. For example the 3rd party package "Dropdown Multiselect" when setting the option of "selectionLimit" to 1 is returning an array while in fact it's a an object. It's returning this `[id: 1, label: 'John']` but in reality this is an object (not an array) and should be this `{id: 1, label: 'John'}` and so because of that, the $scope.$watch never kicks in. - Also added a international phone number validation --- bower.json | 2 +- dist/angular-validation.min.js | 8 ++++---- locales/validation/ca.json | 1 + locales/validation/en.json | 1 + locales/validation/es.json | 1 + locales/validation/fr.json | 1 + locales/validation/no.json | 1 + locales/validation/pl.json | 1 + locales/validation/pt-br.json | 1 + locales/validation/ru.json | 1 + more-examples/addon-3rdParty/index.html | 2 +- package.json | 2 +- readme.md | 2 +- src/validation-directive.js | 13 ++++++++++++- src/validation-rules.js | 8 ++++++++ 15 files changed, 36 insertions(+), 9 deletions(-) diff --git a/bower.json b/bower.json index 01ff7ff..54e4881 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.3", + "version": "1.5.4", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index bd0ac2a..ff0fe2e 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.5.3 + * @version: 1.5.4 * @license: MIT - * @build: Wed Jul 20 2016 21:43:21 GMT-0400 (Eastern Daylight Time) + * @build: Fri Jul 29 2016 01:07:56 GMT-0400 (Eastern Daylight Time) */ -angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,l,r){function o(i,l){var o=a.defer(),d=!1,m="undefined"!=typeof l?l:$.typingLimit,s=$.getFormElementByName(r.$name);if(Array.isArray(i)){if(O=[],E="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||w||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||w)&&r.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),r.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===l?(d=$.validate(i,!0),n.$evalAsync(r.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(r.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(C){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){E.length>0&&g.displayOnlyLastErrorMsg?E="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):E+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(E,{isValid:!1}),$.addToValidationSummary(a.formElmObj,E)});break;case"one":default:a.isFieldValid===!0&&(r.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(r.$name),i="undefined"!=typeof r.$modelValue?r.$modelValue:a.target.value;if(e.isValidationCancelled)r.$setValidity("validation",!0);else{var n=o(i,0);F&&$.runValidationCallbackOnPromise(n,F)}}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var l in t)if(t.hasOwnProperty(l)){if(A&&l!==A)continue;d(t[l],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(h,"elmName",r.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();h.shift()}}function f(){var a=$.getFormElementByName(r.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),r.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){return y()?{badInput:!0}:r.$modelValue},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);F&&$.runValidationCallbackOnPromise(i,F)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(r.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=r.$modelValue||"";Array.isArray(a)||r.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(r.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,l,r),E="",O=[],h=[],g=$.getGlobalOptions(),j=l.name,F=l.hasOwnProperty("validationCallback")?l.validationCallback:null,w=l.hasOwnProperty("validateOnEmpty")?$.parseBool(l.validateOnEmpty):!!g.validateOnEmpty,C=l.hasOwnProperty("validArrayRequireHowMany")?l.validArrayRequireHowMany:"one",A=l.hasOwnProperty("validationArrayObjprop")?l.validationArrayObjprop:null;h.push({elmName:j,watcherHandler:v()}),l.$observe("disabled",function(a){a?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(h,"elmName",r.$name);e||h.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==r.$name){r.revalidateCalled=!0;var i=r.$modelValue;if(t.isValidationCancelled)r.$setValidity("validation",!0);else{var n=o(i);F&&$.runValidationCallbackOnPromise(n,F)}}})}}}]); +angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(w){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i,0);A&&$.runValidationCallbackOnPromise(n,A)}}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);A&&$.runValidationCallbackOnPromise(i,A)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,A=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,w=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i);A&&$.runValidationCallbackOnPromise(n,A)}}})}}}]); angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function i(e,t,r){if("undefined"!=typeof e&&null!=e){var i=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),n=E(i,e),o=w(z,"field",i);if(o>=0&&""===t)z.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:i,friendlyName:s,message:t,formName:n?n.$name:null};o>=0?z[o]=l:z.push(l)}if(e.scope.$validationSummary=z,n&&(n.$validationSummary=A(z,"formName",n.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,n&&n.$name)){var d=n.$name.indexOf(".")>=0?n.$name.split(".")[1]:n.$name,u=_.controllerAs[d]?_.controllerAs[d]:e.elm.controller()[d];u&&(u.$validationSummary=A(z,"formName",n.$name))}return z}}function n(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var i=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!i||i.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var n=i[1],o=i[2]?i[2].replace(/\|(.*)/,""):"",s=n.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+n,"pattern")}else if(a.indexOf("regex:")>=0){var i=a.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 d=i[1].split(":=");t={message:d[0],pattern:d[1]},a=a.replace(i[0],"regex:")}var u=a.split("|");if(u){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=u.length;p=0,g=[];f?(g=u[p].substring(0,c-1).split(":"),g.push(u[p].substring(c))):g=u[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return V(B,"fieldName",e)}function s(e){return e?A(B,"formName",e):B}function l(){return _}function d(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,O(t,a,r,e),this.defineValidation()}function u(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=w(B,"fieldName",e);t>=0&&B.splice(t,1)}function c(e,t){var a=this,r=E(e,a),i=t||z,n=w(i,"field",e);if(n>=0&&i.splice(n,1),n=w(z,"field",e),n>=0&&z.splice(n,1),a.scope.$validationSummary=z,r&&(r.$validationSummary=A(z,"formName",r.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;_.controllerAs[o]&&(_.controllerAs[o].$validationSummary=A(z,"formName",r.$name))}return z}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){_.displayOnlyLastErrorMsg=e}function y(e){var t=this;return _=p(_,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var i=t&&t.elm?t.elm:r.elm,n=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof n||null===n){var o=i?i.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=n.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),d=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var u=r.validatorAttrs.validationErrorTo.charAt(0),p="."===u||"#"===u?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;d=angular.element(document.querySelector(p))}d&&0!==d.length||(d=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!_.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?d.length>0?d.html(s):i.after('
'+s+"
"):d.html("")}function b(e,t){var r,n=this,s=!0,l=!0,d=0,u={message:""};"undefined"==typeof e&&(e="");for(var p=n.ctrl&&n.ctrl.$name?n.ctrl.$name:n.attrs&&n.attrs.name?n.attrs.name:n.elm.attr("name"),m=o(p),c=n.validatorAttrs.rules||n.validatorAttrs.validation,f=0,g=n.validators.length;f0&&(o=i.altText.replace("alt=",""));var d=a(o);e.translatePromise=d,e.validator=i,d.then(function(a){u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+(i&&i.params?String.format(a,i.params):a):u.message+=s+(i&&i.params?String.format(a,i.params):a),$(n,e,u.message,l,t)})["catch"](function(a){i.altText&&i.altText.length>0&&(u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+o:u.message+=s+o,$(n,e,u.message,l,t))})}(m,s,r)),s&&d++,n.validRequireHowMany==d&&s){l=!0;break}}return s&&(i(n,""),n.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function O(e,t,r,i){var n=t.name?t.name:e.attr("name"),o=E(n,{scope:i}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:n,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:i,isValid:!1,message:"",formName:o?o.$name:null},d=w(B,"fieldName",e.attr("name"));return d>=0?B[d]=l:B.push(l),B}function $(e,t,a,r,n){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(_.preValidateValidationSummary||"undefined"==typeof _.preValidateValidationSummary||n)&&i(t,a),(e.validatorAttrs.preValidateFormElements||_.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),n&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&i(t,"")}function S(e){return e.typingLimit=I,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):_&&_.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(_.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:_.validRequireHowMany,K=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):_.validateOnEmpty,e}function V(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(n){var o=n?n.getAttribute("name"):null;if(o){var s={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(_&&_.controllerAs&&o.indexOf(".")>=0){var l=o.split(".");return t.scope[l[0]][l[1]]=s}return t.scope[o]=s}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,i=0,n=r.length;i8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),l=i[0],s=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),i=q(a,r),o=i[0],s=i[1],l=i[2],n=e.length>10?e.substring(11).split(":"):null}var d=n&&3===n.length?n[0]:0,u=n&&3===n.length?n[1]:0,p=n&&3===n.length?n[2]:0;return new Date(o,s-1,l,d,u,p)}function q(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function F(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function k(){return this.replace(/^\s+|\s+$/g,"")}function L(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function M(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function C(e,t,a){var r=!0,i=r=!1;if(e instanceof Date)i=!0;else{var n=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&n.test(e)}if(i){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),d=T(t.params[1],o).getTime(),u=F(t.condition[0],s,l),p=F(t.condition[1],s,d);r=u&&p}else{var m=T(t.params[0],o).getTime();r=F(t.condition,s,m)}}return r}function U(e,t){var a=!0;if(2==t.params.length){var r=F(t.condition[0],parseFloat(e),parseFloat(t.params[0])),i=F(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&i}else a=F(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function j(e,a,r,i,n,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",d="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||K){var u=a.params[0],p=f(r,u);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw d;s=!!p.isValid}if(s===!1?(i.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;$(r,i,e,!1,n)})):s===!0&&(i.isValid=!0,$(r,i,"",!0,n)),"undefined"==typeof p)throw d}return s}function G(e,t,r,i){var n=!0,s=t.params[0],l=r.scope.$eval(s),d=angular.element(document.querySelector('[name="'+s+'"]')),u=t,p=r.ctrl,m=o(r.ctrl.$name);return n=F(t.condition,e,l)&&!!e,d&&d.attr("friendly-name")?t.params[1]=d.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var n=F(u.condition,p.$viewValue,e);if(e!==t){if(n)$(r,m,"",!0,!0);else{m.isValid=!1;var o=u.message;u.altText&&u.altText.length>0&&(o=u.altText.replace("alt=","")),a(o).then(function(e){var t=_.errorMessageSeparator||" ";i.message=t+(u&&u.params?String.format(e,u.params):e),$(r,m,i.message,n,!0)})}p.$setValidity("validation",n)}},!0),n}function H(e,t,a,r,i,n){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&i||K){a.ctrl.$processing=!0;var d=t.params[0],u=f(a,d);if(J.length>1)for(;J.length>0;){var p=J.pop();"function"==typeof p.abort&&p.abort()}if(J.push(u),!u||"function"!=typeof u.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){u.then(function(t){t=t.data||t,J.pop(),a.ctrl.$processing=!1;var d=n.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,d+=t.message||e," "===d)throw s;$(a,r,d,!1,i)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),$(a,r,"",!0,i))})}(t.altText)}return o}function P(e,t,a,r){var i=!0,n=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(n))i=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())i=!1;else{var o=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return i}function D(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var I=1e3,B=[],_={resetGlobalOptionsOnRouteChange:!0},J=[],z=[],K=!1;e.$on("$routeChangeStart",function(e,t,a){_.resetGlobalOptionsOnRouteChange&&(_={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},B=[],z=[])});var Y=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=I,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(_=e.$validationOptions),e&&(_.isolatedScope||_.scope)&&(this.scope=_.isolatedScope||_.scope,_=p(e.$validationOptions,_)),"undefined"==typeof _.resetGlobalOptionsOnRouteChange&&(_.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&(O(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return Y.prototype.addToValidationSummary=i,Y.prototype.arrayFindObject=V,Y.prototype.defineValidation=n,Y.prototype.getFormElementByName=o,Y.prototype.getFormElements=s,Y.prototype.getGlobalOptions=l,Y.prototype.isFieldRequired=u,Y.prototype.initialize=d,Y.prototype.mergeObjects=p,Y.prototype.parseBool=N,Y.prototype.removeFromValidationSummary=c,Y.prototype.removeFromFormElementObjectList=m,Y.prototype.runValidationCallbackOnPromise=g,Y.prototype.setDisplayOnlyLastErrorMsg=v,Y.prototype.setGlobalOptions=y,Y.prototype.updateErrorMsg=h,Y.prototype.validate=b,String.prototype.trim=k,String.prototype.format=L,String.format=M,Y}]); -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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,r={};switch(s){case"accepted":r={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";r={patternLength:"^(.|[\\r\\n]){"+_[0]+","+_[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";r={pattern:"^(.|[\\r\\n]){"+_[0]+","+_[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[_[0],_[1]],type:"regex"};break;case"betweenNum":case"between_num":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";r={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"conditionalNumber"};break;case"boolean":r={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":r={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":r={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":r={message:"",params:[n],type:"javascript"};break;case"dateEuroLong":case"date_euro_long":r={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 _=n.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";r={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":r={condition:"<=",dateType:"EURO_LONG",params:[n],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":r={condition:">=",dateType:"EURO_LONG",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"EURO_SHORT",params:[n],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":r={condition:">=",dateType:"EURO_SHORT",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"ISO",params:[n],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":r={condition:">=",dateType:"ISO",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"US_LONG",params:[n],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":r={condition:">=",dateType:"US_LONG",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"US_SHORT",params:[n],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":r={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");r={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":r={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";r={pattern:"^\\d{"+_[0]+","+_[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[_[0],_[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":r={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":r={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":r={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":r={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":r={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var c=RegExp().escape(n).replace(/,/g,"|");r={pattern:"^("+c+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":r={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":r={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":r={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":r={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");r={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":r={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":r={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":r={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":r={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":r={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":r={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var c=RegExp().escape(n).replace(/,/g,"|");r={pattern:"^((?!("+c+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":r={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":r={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":r={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"pattern":case"regex":r={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":r={message:"",params:[n],type:"remote"};break;case"required":r={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":r={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":r={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":r={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return r.altText=a,r}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; +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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,r={};switch(s){case"accepted":r={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";r={patternLength:"^(.|[\\r\\n]){"+_[0]+","+_[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";r={pattern:"^(.|[\\r\\n]){"+_[0]+","+_[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[_[0],_[1]],type:"regex"};break;case"betweenNum":case"between_num":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";r={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"conditionalNumber"};break;case"boolean":r={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":r={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":r={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":r={message:"",params:[n],type:"javascript"};break;case"dateEuroLong":case"date_euro_long":r={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 _=n.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";r={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":r={condition:"<=",dateType:"EURO_LONG",params:[n],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":r={condition:">=",dateType:"EURO_LONG",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"EURO_SHORT",params:[n],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":r={condition:">=",dateType:"EURO_SHORT",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"ISO",params:[n],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":r={condition:">=",dateType:"ISO",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"US_LONG",params:[n],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":r={condition:">=",dateType:"US_LONG",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"US_SHORT",params:[n],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":r={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");r={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":r={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";r={pattern:"^\\d{"+_[0]+","+_[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[_[0],_[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":r={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":r={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":r={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":r={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":r={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var c=RegExp().escape(n).replace(/,/g,"|");r={pattern:"^("+c+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":r={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":r={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":r={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":r={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");r={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":r={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":r={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":r={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":r={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":r={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":r={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var c=RegExp().escape(n).replace(/,/g,"|");r={pattern:"^((?!("+c+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":r={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":r={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":r={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":r={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":r={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":r={message:"",params:[n],type:"remote"};break;case"required":r={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":r={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":r={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":r={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return r.altText=a,r}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e){var o=this,t="",a=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var n=0,i=e.$validationSummary.length;n0&&("function"==typeof l.ctrl.$setTouched&&l.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:l.isValid,obj:l}))}return a}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;aERRORS! options="vm.select1data" selected-model="vm.select1model" ng-model="vm.select1model" - extra-settings="{externalIdProp: ''}" + extra-settings="{externalIdProp: '', selectionLimit: 1}" validation="in_list:John,Jane|required" validation-array-objprop="label"> diff --git a/package.json b/package.json index 600c23b..abf8816 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.3", + "version": "1.5.4", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": "app.js", diff --git a/readme.md b/readme.md index 2659d11..ef12bb7 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ #Angular Validation (Directive / Service) -`Version: 1.5.3` +`Version: 1.5.4` ### Forms Validation with Angular made easy! ##### (Concept comes from the amazing Laravel) diff --git a/src/validation-directive.js b/src/validation-directive.js index b8b879c..b2bfd49 100644 --- a/src/validation-directive.js +++ b/src/validation-directive.js @@ -349,10 +349,21 @@ */ function createWatch() { return scope.$watch(function() { + var modelValue = ctrl.$modelValue; if(isKeyTypedBadInput()) { return { badInput: true }; } - return ctrl.$modelValue; + else if(!!_validationArrayObjprop && Array.isArray(modelValue) && modelValue.length === 0 && Object.keys(modelValue).length > 0) { + // when the modelValue is an Array but is length 0, this mean it's an Object disguise as an array + // since an Array of length 0 won't trigger a watch change, we need to return it back to an object + // for example Dropdown Multiselect when using selectionLimit of 1 will return [id: 1, label: 'John'], what we really want is the object { id: 1, label: 'John'} + // convert the object array to a real object that will go inside an array + var arr = [], obj = {}; + obj[_validationArrayObjprop] = modelValue[_validationArrayObjprop]; // convert [label: 'John'] to {label: 'John'} + arr.push(obj); // push to array: [{label: 'John'}] + return arr; + } + return modelValue; }, function(newValue, oldValue) { if(!!newValue && !!newValue.badInput) { unbindBlurHandler(); diff --git a/src/validation-rules.js b/src/validation-rules.js index 65a4395..4765b27 100644 --- a/src/validation-rules.js +++ b/src/validation-rules.js @@ -649,6 +649,14 @@ angular type: "regex" }; break; + case "phoneInternational" : + case "phone_international" : + validator = { + pattern: /^\+(?:[0-9]\x20?){6,14}[0-9]$/, + message: "INVALID_PHONE_INTERNATIONAL", + type: "regex" + }; + break; case "pattern" : case "regex" : // Custom User Regex is a special case, the properties (message, pattern) were created and dealt separately prior to the for loop From 8e825d5625276cd7dab27fb57796fb59a4c4eac3 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Fri, 29 Jul 2016 01:34:19 -0400 Subject: [PATCH 06/60] typo --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index a099d71..ac01b91 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.4 (2016-07-29) Fixed an issue with 3rd party validation not triggering a $scope.$watch. Also added new international phone validation (issue #125). 1.5.3 (2016-07-20) Add C# validation annotation, (for example: maxLen => maxLength) 1.5.2 (2016-06-14) Fixed #121 Alternate text containing the char ":" was causing unexpected displayed message. 1.5.1 (2016-03-10) Fixed #111 Add US phone number & tweaked credit card rules. From 72f62bf42017e2cc2c1c79efef5133c5d01e10cd Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Fri, 29 Jul 2016 01:37:49 -0400 Subject: [PATCH 07/60] typo --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index ef12bb7..db5e88c 100644 --- a/readme.md +++ b/readme.md @@ -226,6 +226,8 @@ All validators are written as `snake_case` but it's up to the user's taste and c * `numeric` Only positive numeric value (float, integer). * `numeric_signed` Only numeric value (float, integer) can also be signed (-/+). * `pattern` Ensure it follows a regular expression pattern... Refer to [Wiki - Regular Expression Pattern](https://github.com/ghiscoding/angular-validation/wiki/Regular-Expression-Pattern) on how to use it. +* `phone` Check for a valid phone number (Canada/US) +* `phone_international` Check for a valid international phone number * `range` Alias of `between` * `required` Ensures the specified key value exists and is not empty * `same` Alias of `match`. From ba2ba9a85f1836e5d96a4adab35e67b0a67376a7 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Thu, 1 Sep 2016 00:44:29 -0400 Subject: [PATCH 08/60] If translation isn't working, throw an error --- bower.json | 4 ++-- dist/angular-validation.min.js | 6 +++--- more-examples/customRemote/app.js | 4 ++-- package.json | 2 +- protractor/angularUI_spec.js | 3 +++ protractor/badInput_spec.js | 2 ++ protractor/callback_spec.js | 1 + protractor/conf.js | 2 +- protractor/controllerAsWithRoute_spec.js | 3 +++ protractor/custom_spec.js | 3 +++ protractor/dynamic_spec.js | 4 ++++ protractor/full_tests_spec.js | 3 +++ protractor/interpolate_spec.js | 1 + protractor/mixed_validation_spec.js | 14 ++++++++++++++ protractor/remote_spec.js | 3 +++ protractor/thirdParty_spec.js | 2 ++ protractor/validRequireHowMany_spec.js | 4 ++++ readme.md | 2 +- src/validation-common.js | 2 ++ 19 files changed, 55 insertions(+), 10 deletions(-) diff --git a/bower.json b/bower.json index 54e4881..3fb5fb1 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.4", + "version": "1.5.5", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ @@ -47,4 +47,4 @@ "devDependencies": { "angular-route": ">= 1.2.0" } -} +} \ No newline at end of file diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index ff0fe2e..950be4c 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.5.4 + * @version: 1.5.5 * @license: MIT - * @build: Fri Jul 29 2016 01:07:56 GMT-0400 (Eastern Daylight Time) + * @build: Wed Aug 31 2016 12:59:09 GMT-0400 (Eastern Daylight Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(w){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i,0);A&&$.runValidationCallbackOnPromise(n,A)}}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);A&&$.runValidationCallbackOnPromise(i,A)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,A=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,w=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i);A&&$.runValidationCallbackOnPromise(n,A)}}})}}}]); -angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function i(e,t,r){if("undefined"!=typeof e&&null!=e){var i=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),n=E(i,e),o=w(z,"field",i);if(o>=0&&""===t)z.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:i,friendlyName:s,message:t,formName:n?n.$name:null};o>=0?z[o]=l:z.push(l)}if(e.scope.$validationSummary=z,n&&(n.$validationSummary=A(z,"formName",n.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,n&&n.$name)){var d=n.$name.indexOf(".")>=0?n.$name.split(".")[1]:n.$name,u=_.controllerAs[d]?_.controllerAs[d]:e.elm.controller()[d];u&&(u.$validationSummary=A(z,"formName",n.$name))}return z}}function n(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var i=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!i||i.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var n=i[1],o=i[2]?i[2].replace(/\|(.*)/,""):"",s=n.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+n,"pattern")}else if(a.indexOf("regex:")>=0){var i=a.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 d=i[1].split(":=");t={message:d[0],pattern:d[1]},a=a.replace(i[0],"regex:")}var u=a.split("|");if(u){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=u.length;p=0,g=[];f?(g=u[p].substring(0,c-1).split(":"),g.push(u[p].substring(c))):g=u[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return V(B,"fieldName",e)}function s(e){return e?A(B,"formName",e):B}function l(){return _}function d(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,O(t,a,r,e),this.defineValidation()}function u(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=w(B,"fieldName",e);t>=0&&B.splice(t,1)}function c(e,t){var a=this,r=E(e,a),i=t||z,n=w(i,"field",e);if(n>=0&&i.splice(n,1),n=w(z,"field",e),n>=0&&z.splice(n,1),a.scope.$validationSummary=z,r&&(r.$validationSummary=A(z,"formName",r.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;_.controllerAs[o]&&(_.controllerAs[o].$validationSummary=A(z,"formName",r.$name))}return z}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){_.displayOnlyLastErrorMsg=e}function y(e){var t=this;return _=p(_,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var i=t&&t.elm?t.elm:r.elm,n=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof n||null===n){var o=i?i.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=n.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),d=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var u=r.validatorAttrs.validationErrorTo.charAt(0),p="."===u||"#"===u?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;d=angular.element(document.querySelector(p))}d&&0!==d.length||(d=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!_.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?d.length>0?d.html(s):i.after('
'+s+"
"):d.html("")}function b(e,t){var r,n=this,s=!0,l=!0,d=0,u={message:""};"undefined"==typeof e&&(e="");for(var p=n.ctrl&&n.ctrl.$name?n.ctrl.$name:n.attrs&&n.attrs.name?n.attrs.name:n.elm.attr("name"),m=o(p),c=n.validatorAttrs.rules||n.validatorAttrs.validation,f=0,g=n.validators.length;f0&&(o=i.altText.replace("alt=",""));var d=a(o);e.translatePromise=d,e.validator=i,d.then(function(a){u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+(i&&i.params?String.format(a,i.params):a):u.message+=s+(i&&i.params?String.format(a,i.params):a),$(n,e,u.message,l,t)})["catch"](function(a){i.altText&&i.altText.length>0&&(u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+o:u.message+=s+o,$(n,e,u.message,l,t))})}(m,s,r)),s&&d++,n.validRequireHowMany==d&&s){l=!0;break}}return s&&(i(n,""),n.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function O(e,t,r,i){var n=t.name?t.name:e.attr("name"),o=E(n,{scope:i}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:n,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:i,isValid:!1,message:"",formName:o?o.$name:null},d=w(B,"fieldName",e.attr("name"));return d>=0?B[d]=l:B.push(l),B}function $(e,t,a,r,n){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(_.preValidateValidationSummary||"undefined"==typeof _.preValidateValidationSummary||n)&&i(t,a),(e.validatorAttrs.preValidateFormElements||_.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),n&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&i(t,"")}function S(e){return e.typingLimit=I,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):_&&_.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(_.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:_.validRequireHowMany,K=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):_.validateOnEmpty,e}function V(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(n){var o=n?n.getAttribute("name"):null;if(o){var s={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(_&&_.controllerAs&&o.indexOf(".")>=0){var l=o.split(".");return t.scope[l[0]][l[1]]=s}return t.scope[o]=s}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,i=0,n=r.length;i8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),l=i[0],s=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),i=q(a,r),o=i[0],s=i[1],l=i[2],n=e.length>10?e.substring(11).split(":"):null}var d=n&&3===n.length?n[0]:0,u=n&&3===n.length?n[1]:0,p=n&&3===n.length?n[2]:0;return new Date(o,s-1,l,d,u,p)}function q(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function F(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function k(){return this.replace(/^\s+|\s+$/g,"")}function L(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function M(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function C(e,t,a){var r=!0,i=r=!1;if(e instanceof Date)i=!0;else{var n=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&n.test(e)}if(i){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),d=T(t.params[1],o).getTime(),u=F(t.condition[0],s,l),p=F(t.condition[1],s,d);r=u&&p}else{var m=T(t.params[0],o).getTime();r=F(t.condition,s,m)}}return r}function U(e,t){var a=!0;if(2==t.params.length){var r=F(t.condition[0],parseFloat(e),parseFloat(t.params[0])),i=F(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&i}else a=F(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function j(e,a,r,i,n,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",d="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||K){var u=a.params[0],p=f(r,u);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw d;s=!!p.isValid}if(s===!1?(i.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;$(r,i,e,!1,n)})):s===!0&&(i.isValid=!0,$(r,i,"",!0,n)),"undefined"==typeof p)throw d}return s}function G(e,t,r,i){var n=!0,s=t.params[0],l=r.scope.$eval(s),d=angular.element(document.querySelector('[name="'+s+'"]')),u=t,p=r.ctrl,m=o(r.ctrl.$name);return n=F(t.condition,e,l)&&!!e,d&&d.attr("friendly-name")?t.params[1]=d.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var n=F(u.condition,p.$viewValue,e);if(e!==t){if(n)$(r,m,"",!0,!0);else{m.isValid=!1;var o=u.message;u.altText&&u.altText.length>0&&(o=u.altText.replace("alt=","")),a(o).then(function(e){var t=_.errorMessageSeparator||" ";i.message=t+(u&&u.params?String.format(e,u.params):e),$(r,m,i.message,n,!0)})}p.$setValidity("validation",n)}},!0),n}function H(e,t,a,r,i,n){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&i||K){a.ctrl.$processing=!0;var d=t.params[0],u=f(a,d);if(J.length>1)for(;J.length>0;){var p=J.pop();"function"==typeof p.abort&&p.abort()}if(J.push(u),!u||"function"!=typeof u.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){u.then(function(t){t=t.data||t,J.pop(),a.ctrl.$processing=!1;var d=n.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,d+=t.message||e," "===d)throw s;$(a,r,d,!1,i)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),$(a,r,"",!0,i))})}(t.altText)}return o}function P(e,t,a,r){var i=!0,n=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(n))i=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())i=!1;else{var o=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return i}function D(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var I=1e3,B=[],_={resetGlobalOptionsOnRouteChange:!0},J=[],z=[],K=!1;e.$on("$routeChangeStart",function(e,t,a){_.resetGlobalOptionsOnRouteChange&&(_={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},B=[],z=[])});var Y=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=I,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(_=e.$validationOptions),e&&(_.isolatedScope||_.scope)&&(this.scope=_.isolatedScope||_.scope,_=p(e.$validationOptions,_)),"undefined"==typeof _.resetGlobalOptionsOnRouteChange&&(_.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&(O(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return Y.prototype.addToValidationSummary=i,Y.prototype.arrayFindObject=V,Y.prototype.defineValidation=n,Y.prototype.getFormElementByName=o,Y.prototype.getFormElements=s,Y.prototype.getGlobalOptions=l,Y.prototype.isFieldRequired=u,Y.prototype.initialize=d,Y.prototype.mergeObjects=p,Y.prototype.parseBool=N,Y.prototype.removeFromValidationSummary=c,Y.prototype.removeFromFormElementObjectList=m,Y.prototype.runValidationCallbackOnPromise=g,Y.prototype.setDisplayOnlyLastErrorMsg=v,Y.prototype.setGlobalOptions=y,Y.prototype.updateErrorMsg=h,Y.prototype.validate=b,String.prototype.trim=k,String.prototype.format=L,String.format=M,Y}]); +angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function i(e,t,r){if("undefined"!=typeof e&&null!=e){var i=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),n=E(i,e),o=w(z,"field",i);if(o>=0&&""===t)z.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:i,friendlyName:s,message:t,formName:n?n.$name:null};o>=0?z[o]=l:z.push(l)}if(e.scope.$validationSummary=z,n&&(n.$validationSummary=V(z,"formName",n.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,n&&n.$name)){var d=n.$name.indexOf(".")>=0?n.$name.split(".")[1]:n.$name,u=_.controllerAs[d]?_.controllerAs[d]:e.elm.controller()[d];u&&(u.$validationSummary=V(z,"formName",n.$name))}return z}}function n(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var i=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!i||i.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var n=i[1],o=i[2]?i[2].replace(/\|(.*)/,""):"",s=n.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+n,"pattern")}else if(a.indexOf("regex:")>=0){var i=a.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 d=i[1].split(":=");t={message:d[0],pattern:d[1]},a=a.replace(i[0],"regex:")}var u=a.split("|");if(u){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=u.length;p=0,g=[];f?(g=u[p].substring(0,c-1).split(":"),g.push(u[p].substring(c))):g=u[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return A(B,"fieldName",e)}function s(e){return e?V(B,"formName",e):B}function l(){return _}function d(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function u(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=w(B,"fieldName",e);t>=0&&B.splice(t,1)}function c(e,t){var a=this,r=E(e,a),i=t||z,n=w(i,"field",e);if(n>=0&&i.splice(n,1),n=w(z,"field",e),n>=0&&z.splice(n,1),a.scope.$validationSummary=z,r&&(r.$validationSummary=V(z,"formName",r.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;_.controllerAs[o]&&(_.controllerAs[o].$validationSummary=V(z,"formName",r.$name))}return z}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){_.displayOnlyLastErrorMsg=e}function y(e){var t=this;return _=p(_,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var i=t&&t.elm?t.elm:r.elm,n=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof n||null===n){var o=i?i.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=n.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),d=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var u=r.validatorAttrs.validationErrorTo.charAt(0),p="."===u||"#"===u?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;d=angular.element(document.querySelector(p))}d&&0!==d.length||(d=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!_.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?d.length>0?d.html(s):i.after('
'+s+"
"):d.html("")}function b(e,t){var r,n=this,s=!0,l=!0,d=0,u={message:""};"undefined"==typeof e&&(e="");for(var p=n.ctrl&&n.ctrl.$name?n.ctrl.$name:n.attrs&&n.attrs.name?n.attrs.name:n.elm.attr("name"),m=o(p),c=n.validatorAttrs.rules||n.validatorAttrs.validation,f=0,g=n.validators.length;f0&&(o=i.altText.replace("alt=",""));var d=a(o);e.translatePromise=d,e.validator=i,d.then(function(a){u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+(i&&i.params?String.format(a,i.params):a):u.message+=s+(i&&i.params?String.format(a,i.params):a),O(n,e,u.message,l,t)})["catch"](function(a){if(!(i.altText&&i.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+o:u.message+=s+o,O(n,e,u.message,l,t)})}(m,s,r)),s&&d++,n.validRequireHowMany==d&&s){l=!0;break}}return s&&(i(n,""),n.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,i){var n=t.name?t.name:e.attr("name"),o=E(n,{scope:i}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:n,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:i,isValid:!1,message:"",formName:o?o.$name:null},d=w(B,"fieldName",e.attr("name"));return d>=0?B[d]=l:B.push(l),B}function O(e,t,a,r,n){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(_.preValidateValidationSummary||"undefined"==typeof _.preValidateValidationSummary||n)&&i(t,a),(e.validatorAttrs.preValidateFormElements||_.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),n&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&i(t,"")}function S(e){return e.typingLimit=I,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):_&&_.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(_.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:_.validRequireHowMany,K=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):_.validateOnEmpty,e}function A(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(n){var o=n?n.getAttribute("name"):null;if(o){var s={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(_&&_.controllerAs&&o.indexOf(".")>=0){var l=o.split(".");return t.scope[l[0]][l[1]]=s}return t.scope[o]=s}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,i=0,n=r.length;i8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),l=i[0],s=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),i=q(a,r),o=i[0],s=i[1],l=i[2],n=e.length>10?e.substring(11).split(":"):null}var d=n&&3===n.length?n[0]:0,u=n&&3===n.length?n[1]:0,p=n&&3===n.length?n[2]:0;return new Date(o,s-1,l,d,u,p)}function q(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function F(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function k(){return this.replace(/^\s+|\s+$/g,"")}function L(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function M(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function C(e,t,a){var r=!0,i=r=!1;if(e instanceof Date)i=!0;else{var n=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&n.test(e)}if(i){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),d=T(t.params[1],o).getTime(),u=F(t.condition[0],s,l),p=F(t.condition[1],s,d);r=u&&p}else{var m=T(t.params[0],o).getTime();r=F(t.condition,s,m)}}return r}function U(e,t){var a=!0;if(2==t.params.length){var r=F(t.condition[0],parseFloat(e),parseFloat(t.params[0])),i=F(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&i}else a=F(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function P(e,a,r,i,n,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",d="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||K){var u=a.params[0],p=f(r,u);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw d;s=!!p.isValid}if(s===!1?(i.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,i,e,!1,n)})):s===!0&&(i.isValid=!0,O(r,i,"",!0,n)),"undefined"==typeof p)throw d}return s}function j(e,t,r,i){var n=!0,s=t.params[0],l=r.scope.$eval(s),d=angular.element(document.querySelector('[name="'+s+'"]')),u=t,p=r.ctrl,m=o(r.ctrl.$name);return n=F(t.condition,e,l)&&!!e,d&&d.attr("friendly-name")?t.params[1]=d.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var n=F(u.condition,p.$viewValue,e);if(e!==t){if(n)O(r,m,"",!0,!0);else{m.isValid=!1;var o=u.message;u.altText&&u.altText.length>0&&(o=u.altText.replace("alt=","")),a(o).then(function(e){var t=_.errorMessageSeparator||" ";i.message=t+(u&&u.params?String.format(e,u.params):e),O(r,m,i.message,n,!0)})}p.$setValidity("validation",n)}},!0),n}function G(e,t,a,r,i,n){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&i||K){a.ctrl.$processing=!0;var d=t.params[0],u=f(a,d);if(J.length>1)for(;J.length>0;){var p=J.pop();"function"==typeof p.abort&&p.abort()}if(J.push(u),!u||"function"!=typeof u.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){u.then(function(t){t=t.data||t,J.pop(),a.ctrl.$processing=!1;var d=n.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,d+=t.message||e," "===d)throw s;O(a,r,d,!1,i)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,i))})}(t.altText)}return o}function H(e,t,a,r){var i=!0,n=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(n))i=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())i=!1;else{var o=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return i}function D(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var I=1e3,B=[],_={resetGlobalOptionsOnRouteChange:!0},J=[],z=[],K=!1;e.$on("$routeChangeStart",function(e,t,a){_.resetGlobalOptionsOnRouteChange&&(_={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},B=[],z=[])});var Y=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=I,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(_=e.$validationOptions),e&&(_.isolatedScope||_.scope)&&(this.scope=_.isolatedScope||_.scope,_=p(e.$validationOptions,_)),"undefined"==typeof _.resetGlobalOptionsOnRouteChange&&(_.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return Y.prototype.addToValidationSummary=i,Y.prototype.arrayFindObject=A,Y.prototype.defineValidation=n,Y.prototype.getFormElementByName=o,Y.prototype.getFormElements=s,Y.prototype.getGlobalOptions=l,Y.prototype.isFieldRequired=u,Y.prototype.initialize=d,Y.prototype.mergeObjects=p,Y.prototype.parseBool=N,Y.prototype.removeFromValidationSummary=c,Y.prototype.removeFromFormElementObjectList=m,Y.prototype.runValidationCallbackOnPromise=g,Y.prototype.setDisplayOnlyLastErrorMsg=v,Y.prototype.setGlobalOptions=y,Y.prototype.updateErrorMsg=h,Y.prototype.validate=b,String.prototype.trim=k,String.prototype.format=L,String.format=M,Y}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,r={};switch(s){case"accepted":r={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";r={patternLength:"^(.|[\\r\\n]){"+_[0]+","+_[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";r={pattern:"^(.|[\\r\\n]){"+_[0]+","+_[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[_[0],_[1]],type:"regex"};break;case"betweenNum":case"between_num":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";r={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"conditionalNumber"};break;case"boolean":r={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":r={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":r={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":r={message:"",params:[n],type:"javascript"};break;case"dateEuroLong":case"date_euro_long":r={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 _=n.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";r={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":r={condition:"<=",dateType:"EURO_LONG",params:[n],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":r={condition:">=",dateType:"EURO_LONG",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"EURO_SHORT",params:[n],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":r={condition:">=",dateType:"EURO_SHORT",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"ISO",params:[n],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":r={condition:">=",dateType:"ISO",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"US_LONG",params:[n],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":r={condition:">=",dateType:"US_LONG",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"US_SHORT",params:[n],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":r={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");r={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":r={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";r={pattern:"^\\d{"+_[0]+","+_[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[_[0],_[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":r={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":r={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":r={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":r={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":r={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var c=RegExp().escape(n).replace(/,/g,"|");r={pattern:"^("+c+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":r={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":r={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":r={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":r={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");r={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":r={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":r={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":r={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":r={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":r={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":r={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var c=RegExp().escape(n).replace(/,/g,"|");r={pattern:"^((?!("+c+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":r={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":r={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":r={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":r={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":r={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":r={message:"",params:[n],type:"remote"};break;case"required":r={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":r={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":r={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":r={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return r.altText=a,r}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e){var o=this,t="",a=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var n=0,i=e.$validationSummary.length;n0&&("function"==typeof l.ctrl.$setTouched&&l.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:l.isValid,obj:l}))}return a}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a Date: Sat, 24 Sep 2016 12:36:55 -0400 Subject: [PATCH 09/60] Dates validator now checks for leap year, fix #130 - Prior to this change, Dates validator had basic tests on them and it wasn't validating leap year. Now it does check for leap year and also check for a valid calendar date. - Note: Short dates are deprecated and weren't part of this change, I spent too much time trying to adapt regex I found. If someone want to fix them, please make a PR and I'll be happy :) --- bower.json | 2 +- dist/angular-validation.min.js | 6 +- full-tests/app.js | 34 ++++---- locales/validation/ca.json | 8 ++ locales/validation/en.json | 8 ++ locales/validation/es.json | 8 ++ locales/validation/fr.json | 8 ++ locales/validation/no.json | 8 ++ locales/validation/pl.json | 8 ++ locales/validation/pt-br.json | 8 ++ locales/validation/ru.json | 8 ++ package.json | 2 +- protractor/full_tests_spec.js | 58 ++++++------- protractor/mixed_validation_spec.js | 8 +- readme.md | 44 ++++++---- src/validation-rules.js | 127 +++++++++++++++++++++++++--- 16 files changed, 263 insertions(+), 82 deletions(-) diff --git a/bower.json b/bower.json index 3fb5fb1..a9b384a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.5", + "version": "1.5.6", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 950be4c..2c97c4a 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.5.5 + * @version: 1.5.6 * @license: MIT - * @build: Wed Aug 31 2016 12:59:09 GMT-0400 (Eastern Daylight Time) + * @build: Sat Sep 24 2016 00:49:05 GMT-0400 (Eastern Daylight Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(w){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i,0);A&&$.runValidationCallbackOnPromise(n,A)}}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);A&&$.runValidationCallbackOnPromise(i,A)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,A=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,w=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i);A&&$.runValidationCallbackOnPromise(n,A)}}})}}}]); angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function i(e,t,r){if("undefined"!=typeof e&&null!=e){var i=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),n=E(i,e),o=w(z,"field",i);if(o>=0&&""===t)z.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:i,friendlyName:s,message:t,formName:n?n.$name:null};o>=0?z[o]=l:z.push(l)}if(e.scope.$validationSummary=z,n&&(n.$validationSummary=V(z,"formName",n.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,n&&n.$name)){var d=n.$name.indexOf(".")>=0?n.$name.split(".")[1]:n.$name,u=_.controllerAs[d]?_.controllerAs[d]:e.elm.controller()[d];u&&(u.$validationSummary=V(z,"formName",n.$name))}return z}}function n(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var i=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!i||i.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var n=i[1],o=i[2]?i[2].replace(/\|(.*)/,""):"",s=n.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+n,"pattern")}else if(a.indexOf("regex:")>=0){var i=a.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 d=i[1].split(":=");t={message:d[0],pattern:d[1]},a=a.replace(i[0],"regex:")}var u=a.split("|");if(u){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=u.length;p=0,g=[];f?(g=u[p].substring(0,c-1).split(":"),g.push(u[p].substring(c))):g=u[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return A(B,"fieldName",e)}function s(e){return e?V(B,"formName",e):B}function l(){return _}function d(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function u(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=w(B,"fieldName",e);t>=0&&B.splice(t,1)}function c(e,t){var a=this,r=E(e,a),i=t||z,n=w(i,"field",e);if(n>=0&&i.splice(n,1),n=w(z,"field",e),n>=0&&z.splice(n,1),a.scope.$validationSummary=z,r&&(r.$validationSummary=V(z,"formName",r.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;_.controllerAs[o]&&(_.controllerAs[o].$validationSummary=V(z,"formName",r.$name))}return z}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){_.displayOnlyLastErrorMsg=e}function y(e){var t=this;return _=p(_,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var i=t&&t.elm?t.elm:r.elm,n=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof n||null===n){var o=i?i.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=n.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),d=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var u=r.validatorAttrs.validationErrorTo.charAt(0),p="."===u||"#"===u?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;d=angular.element(document.querySelector(p))}d&&0!==d.length||(d=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!_.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?d.length>0?d.html(s):i.after('
'+s+"
"):d.html("")}function b(e,t){var r,n=this,s=!0,l=!0,d=0,u={message:""};"undefined"==typeof e&&(e="");for(var p=n.ctrl&&n.ctrl.$name?n.ctrl.$name:n.attrs&&n.attrs.name?n.attrs.name:n.elm.attr("name"),m=o(p),c=n.validatorAttrs.rules||n.validatorAttrs.validation,f=0,g=n.validators.length;f0&&(o=i.altText.replace("alt=",""));var d=a(o);e.translatePromise=d,e.validator=i,d.then(function(a){u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+(i&&i.params?String.format(a,i.params):a):u.message+=s+(i&&i.params?String.format(a,i.params):a),O(n,e,u.message,l,t)})["catch"](function(a){if(!(i.altText&&i.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+o:u.message+=s+o,O(n,e,u.message,l,t)})}(m,s,r)),s&&d++,n.validRequireHowMany==d&&s){l=!0;break}}return s&&(i(n,""),n.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,i){var n=t.name?t.name:e.attr("name"),o=E(n,{scope:i}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:n,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:i,isValid:!1,message:"",formName:o?o.$name:null},d=w(B,"fieldName",e.attr("name"));return d>=0?B[d]=l:B.push(l),B}function O(e,t,a,r,n){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(_.preValidateValidationSummary||"undefined"==typeof _.preValidateValidationSummary||n)&&i(t,a),(e.validatorAttrs.preValidateFormElements||_.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),n&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&i(t,"")}function S(e){return e.typingLimit=I,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):_&&_.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(_.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:_.validRequireHowMany,K=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):_.validateOnEmpty,e}function A(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(n){var o=n?n.getAttribute("name"):null;if(o){var s={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(_&&_.controllerAs&&o.indexOf(".")>=0){var l=o.split(".");return t.scope[l[0]][l[1]]=s}return t.scope[o]=s}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,i=0,n=r.length;i8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),l=i[0],s=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),i=q(a,r),o=i[0],s=i[1],l=i[2],n=e.length>10?e.substring(11).split(":"):null}var d=n&&3===n.length?n[0]:0,u=n&&3===n.length?n[1]:0,p=n&&3===n.length?n[2]:0;return new Date(o,s-1,l,d,u,p)}function q(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function F(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function k(){return this.replace(/^\s+|\s+$/g,"")}function L(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function M(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function C(e,t,a){var r=!0,i=r=!1;if(e instanceof Date)i=!0;else{var n=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&n.test(e)}if(i){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),d=T(t.params[1],o).getTime(),u=F(t.condition[0],s,l),p=F(t.condition[1],s,d);r=u&&p}else{var m=T(t.params[0],o).getTime();r=F(t.condition,s,m)}}return r}function U(e,t){var a=!0;if(2==t.params.length){var r=F(t.condition[0],parseFloat(e),parseFloat(t.params[0])),i=F(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&i}else a=F(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function P(e,a,r,i,n,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",d="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||K){var u=a.params[0],p=f(r,u);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw d;s=!!p.isValid}if(s===!1?(i.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,i,e,!1,n)})):s===!0&&(i.isValid=!0,O(r,i,"",!0,n)),"undefined"==typeof p)throw d}return s}function j(e,t,r,i){var n=!0,s=t.params[0],l=r.scope.$eval(s),d=angular.element(document.querySelector('[name="'+s+'"]')),u=t,p=r.ctrl,m=o(r.ctrl.$name);return n=F(t.condition,e,l)&&!!e,d&&d.attr("friendly-name")?t.params[1]=d.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var n=F(u.condition,p.$viewValue,e);if(e!==t){if(n)O(r,m,"",!0,!0);else{m.isValid=!1;var o=u.message;u.altText&&u.altText.length>0&&(o=u.altText.replace("alt=","")),a(o).then(function(e){var t=_.errorMessageSeparator||" ";i.message=t+(u&&u.params?String.format(e,u.params):e),O(r,m,i.message,n,!0)})}p.$setValidity("validation",n)}},!0),n}function G(e,t,a,r,i,n){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&i||K){a.ctrl.$processing=!0;var d=t.params[0],u=f(a,d);if(J.length>1)for(;J.length>0;){var p=J.pop();"function"==typeof p.abort&&p.abort()}if(J.push(u),!u||"function"!=typeof u.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){u.then(function(t){t=t.data||t,J.pop(),a.ctrl.$processing=!1;var d=n.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,d+=t.message||e," "===d)throw s;O(a,r,d,!1,i)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,i))})}(t.altText)}return o}function H(e,t,a,r){var i=!0,n=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(n))i=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())i=!1;else{var o=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return i}function D(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var I=1e3,B=[],_={resetGlobalOptionsOnRouteChange:!0},J=[],z=[],K=!1;e.$on("$routeChangeStart",function(e,t,a){_.resetGlobalOptionsOnRouteChange&&(_={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},B=[],z=[])});var Y=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=I,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(_=e.$validationOptions),e&&(_.isolatedScope||_.scope)&&(this.scope=_.isolatedScope||_.scope,_=p(e.$validationOptions,_)),"undefined"==typeof _.resetGlobalOptionsOnRouteChange&&(_.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return Y.prototype.addToValidationSummary=i,Y.prototype.arrayFindObject=A,Y.prototype.defineValidation=n,Y.prototype.getFormElementByName=o,Y.prototype.getFormElements=s,Y.prototype.getGlobalOptions=l,Y.prototype.isFieldRequired=u,Y.prototype.initialize=d,Y.prototype.mergeObjects=p,Y.prototype.parseBool=N,Y.prototype.removeFromValidationSummary=c,Y.prototype.removeFromFormElementObjectList=m,Y.prototype.runValidationCallbackOnPromise=g,Y.prototype.setDisplayOnlyLastErrorMsg=v,Y.prototype.setGlobalOptions=y,Y.prototype.updateErrorMsg=h,Y.prototype.validate=b,String.prototype.trim=k,String.prototype.format=L,String.format=M,Y}]); -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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,r={};switch(s){case"accepted":r={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";r={patternLength:"^(.|[\\r\\n]){"+_[0]+","+_[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";r={pattern:"^(.|[\\r\\n]){"+_[0]+","+_[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[_[0],_[1]],type:"regex"};break;case"betweenNum":case"between_num":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";r={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"conditionalNumber"};break;case"boolean":r={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":r={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":r={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":r={message:"",params:[n],type:"javascript"};break;case"dateEuroLong":case"date_euro_long":r={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 _=n.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";r={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":r={condition:"<=",dateType:"EURO_LONG",params:[n],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":r={condition:">=",dateType:"EURO_LONG",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"EURO_SHORT",params:[n],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":r={condition:">=",dateType:"EURO_SHORT",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"ISO",params:[n],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":r={condition:">=",dateType:"ISO",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"US_LONG",params:[n],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":r={condition:">=",dateType:"US_LONG",params:[n],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":r={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 _=n.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";r={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":r={condition:"<=",dateType:"US_SHORT",params:[n],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":r={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");r={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":r={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";r={pattern:"^\\d{"+_[0]+","+_[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[_[0],_[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":r={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":r={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":r={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":r={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":r={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var c=RegExp().escape(n).replace(/,/g,"|");r={pattern:"^("+c+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":r={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":r={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":r={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":r={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");r={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":r={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":r={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":r={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":r={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":r={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":r={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var c=RegExp().escape(n).replace(/,/g,"|");r={pattern:"^((?!("+c+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":r={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":r={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":r={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":r={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":r={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":r={message:"",params:[n],type:"remote"};break;case"required":r={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":r={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":r={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":r={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return r.altText=a,r}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; +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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e){var o=this,t="",a=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var n=0,i=e.$validationSummary.length;n0&&("function"==typeof l.ctrl.$setTouched&&l.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:l.isValid,obj:l}))}return a}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a` will display :: *Field must be different from specified field "First Name"*. * `different_input:f,t` Must be different from another input field(f), same as (different:f) but also include (t) for alternate input name to be displayed in the error message (it still uses a generic error message, if you really wish to replace the full error message then you should use `match:n:alt` see [:alt](https://github.com/ghiscoding/angular-validation/wiki/Alternate-Text-on-Validators)) @@ -204,20 +214,24 @@ All validators are written as `snake_case` but it's up to the user's taste and c * `max:n` Will auto-detect value type then use proper validator. * Type Number uses `max_num`, String use `max_len`. * `max_date_iso` Alias of `date_iso_max`. +* `max_date_euro` Alias of `date_euro_max`. * `max_date_euro_long` Alias of `date_euro_long_max`. -* `max_date_euro_short` Alias of `date_euro_short_max`. +* `max_date_euro_short` *DEPRECATED* does not support leap year, preferable to use `max_date_euro` or make a PR to fix it. +* `max_date_us` Alias of `date_us_max`. * `max_date_us_long` Alias of `date_us_long_max`. -* `max_date_us_short` Alias of `date_us_short_max`. +* `max_date_us_short` *DEPRECATED* does not support leap year, preferable to use `max_date_us` or make a PR to fix it. * `max_len:n` Checks field length, no longer than specified length where (n) is length parameter. * `max_length:n` Alias of `max_len` * `max_num:n` Checks numeric value to be lower or equal than the number (n). * `min:n` Will auto-detect value type then use proper validator. * Type Number uses `min_num`, String use `min_len`. * `min_date_iso` Alias of `date_iso_min`. +* `min_date_euro` Alias of `date_euro_min`. * `min_date_euro_long` Alias of `date_euro_long_min`. -* `min_date_euro_short` Alias of `date_euro_short_min`. +* `min_date_euro_short` *DEPRECATED* does not support leap year, preferable to use `min_date_euro` or make a PR to fix it. +* `min_date_us` Alias of `date_us_min`. * `min_date_us_long` Alias of `date_us_long_min`. -* `min_date_us_short` Alias of `date_us_short_min`. +* `min_date_us_short` *DEPRECATED* does not support leap year, preferable to use `min_date-us` or make a PR to fix it. * `min_len:n` Checks field length, no shorter than specified length where (n) is length parameter. * `min_length:n` Alias of `min_len` * `min_num:n` Checks numeric value to be higher or equal than the number (n). diff --git a/src/validation-rules.js b/src/validation-rules.js index 4765b27..1f53ec9 100644 --- a/src/validation-rules.js +++ b/src/validation-rules.js @@ -166,10 +166,62 @@ angular type: "javascript" }; break; + case "dateEuro" : + case "date_euro" : + validator = { + // accept long & short year (1996 or 96) + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_EURO", + type: "regex" + }; + break; + case "dateEuroBetween" : + case "date_euro_between" : + case "betweenDateEuro" : + case "between_date_euro" : + var ranges = ruleParams.split(','); + if (ranges.length !== 2) { + throw "This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015"; + } + validator = { + condition: [">=","<="], + dateType: "EURO_LONG", + params: [ranges[0], ranges[1]], + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_EURO_BETWEEN", + type: "conditionalDate" + }; + break; + case "dateEuroMax" : + case "date_euro_max" : + case "maxDateEuro" : + case "max_date_euro" : + validator = { + condition: "<=", + dateType: "EURO_LONG", + params: [ruleParams], + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_EURO_MAX", + type: "conditionalDate" + }; + break; + case "dateEuroMin" : + case "date_euro_min" : + case "minDateEuro" : + case "min_date_euro" : + validator = { + condition: ">=", + dateType: "EURO_LONG", + params: [ruleParams], + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_EURO_MIN", + type: "conditionalDate" + }; + break; case "dateEuroLong" : case "date_euro_long" : validator = { - pattern: /^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_EURO_LONG", type: "regex" }; @@ -186,7 +238,7 @@ angular condition: [">=","<="], dateType: "EURO_LONG", params: [ranges[0], ranges[1]], - pattern: /^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_EURO_LONG_BETWEEN", type: "conditionalDate" }; @@ -199,7 +251,7 @@ angular condition: "<=", dateType: "EURO_LONG", params: [ruleParams], - pattern: /^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_EURO_LONG_MAX", type: "conditionalDate" }; @@ -212,7 +264,7 @@ angular condition: ">=", dateType: "EURO_LONG", params: [ruleParams], - pattern: /^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_EURO_LONG_MIN", type: "conditionalDate" }; @@ -271,7 +323,7 @@ angular case "dateIso" : case "date_iso" : validator = { - pattern: /^(19|20)\d\d([-])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/, + pattern: /^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/, message: "INVALID_DATE_ISO", type: "regex" }; @@ -288,7 +340,7 @@ angular condition: [">=","<="], dateType: "ISO", params: [ranges[0], ranges[1]], - pattern: /^(19|20)\d\d([-])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/, + pattern: /^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/, message: "INVALID_DATE_ISO_BETWEEN", type: "conditionalDate" }; @@ -301,7 +353,7 @@ angular condition: "<=", dateType: "ISO", params: [ruleParams], - pattern: /^(19|20)\d\d([-])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/, + pattern: /^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/, message: "INVALID_DATE_ISO_MAX", type: "conditionalDate" }; @@ -314,15 +366,66 @@ angular condition: ">=", dateType: "ISO", params: [ruleParams], - pattern: /^(19|20)\d\d([-])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/, + pattern: /^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/, message: "INVALID_DATE_ISO_MIN", type: "conditionalDate" }; break; + case "dateUs" : + case "date_us" : + validator = { + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_US", + type: "regex" + }; + break; + case "dateUsBetween" : + case "date_us_between" : + case "betweenDateUs" : + case "between_date_us" : + var ranges = ruleParams.split(','); + if (ranges.length !== 2) { + throw "This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015"; + } + validator = { + condition: [">=","<="], + dateType: "US_LONG", + params: [ranges[0], ranges[1]], + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_US_BETWEEN", + type: "conditionalDate" + }; + break; + case "dateUsMax" : + case "date_us_max" : + case "maxDateUs" : + case "max_date_us" : + validator = { + condition: "<=", + dateType: "US_LONG", + params: [ruleParams], + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_US_MAX", + type: "conditionalDate" + }; + break; + case "dateUsMin" : + case "date_us_min" : + case "minDateUs" : + case "min_date_us" : + validator = { + condition: ">=", + dateType: "US_LONG", + params: [ruleParams], + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_US_MIN", + type: "conditionalDate" + }; + break; case "dateUsLong" : case "date_us_long" : validator = { - pattern: /^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_US_LONG", type: "regex" }; @@ -339,7 +442,7 @@ angular condition: [">=","<="], dateType: "US_LONG", params: [ranges[0], ranges[1]], - pattern: /^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_US_LONG_BETWEEN", type: "conditionalDate" }; @@ -352,7 +455,7 @@ angular condition: "<=", dateType: "US_LONG", params: [ruleParams], - pattern: /^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_US_LONG_MAX", type: "conditionalDate" }; @@ -365,7 +468,7 @@ angular condition: ">=", dateType: "US_LONG", params: [ruleParams], - pattern: /^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_US_LONG_MIN", type: "conditionalDate" }; From 089072fd7546109cf69e4ce896b99c73cf8c5af4 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Mon, 3 Oct 2016 20:50:10 -0400 Subject: [PATCH 10/60] Add Dutch and Romanian #134 Thanks @jdriesen for providing these 2 locales: Dutch and Romanian --- locales/validation/nl.json | 128 +++++++++++++++++++++++++++++++++++++ locales/validation/ro.json | 105 ++++++++++++++++++++++++++++++ 2 files changed, 233 insertions(+) create mode 100644 locales/validation/nl.json create mode 100644 locales/validation/ro.json diff --git a/locales/validation/nl.json b/locales/validation/nl.json new file mode 100644 index 0000000..bc7cbd1 --- /dev/null +++ b/locales/validation/nl.json @@ -0,0 +1,128 @@ +{ + "INVALID_ACCEPTED": "Dient aanvaard te worden. ", + "INVALID_ALPHA": "Enkel letters zijn toegestaan. ", + "INVALID_ALPHA_SPACE": "Enkel letters en spaties zijn toegestaan. ", + "INVALID_ALPHA_NUM": "Enkel letters en nummers zijn toegestaan. ", + "INVALID_ALPHA_NUM_SPACE": "Enkel letters, nummers en spaties zijn toegestaan. ", + "INVALID_ALPHA_DASH": "Enkel letters, nummers en dashes zijn toegestaan. ", + "INVALID_ALPHA_DASH_SPACE": "Enkel letters, nummers, dashes en spaties zijn toegestaan. ", + "INVALID_BETWEEN_CHAR": "Tekst dient tussen {0} en {1} karakters lang te zijn. ", + "INVALID_BETWEEN_NUM": "Dient een numerische waarde te zijn tussen {0} en {1}. ", + "INVALID_BOOLEAN": "Mag enkel een boolean waarde zijn. ", + "INVALID_CREDIT_CARD": "Dient een geldige creditcard nummer te zijn. ", + "INVALID_DATE_EURO": "Dient een geldig EURO datum formaat te zijn (dd-mm-jjjj) OF (dd/mm/jjjj). ", + "INVALID_DATE_EURO_BETWEEN": "Dient een geldig EURO datum formaat te zijn (dd-mm-jjjj) OF (dd/mm/jjjj) tussen {0} en {1}. ", + "INVALID_DATE_EURO_MAX": "Dient een geldig EURO datum formaat te zijn (dd-mm-jjjj) OF (dd/mm/jjjj), gelijk aan, of kleiner dan {0}. ", + "INVALID_DATE_EURO_MIN": "Dient een geldig EURO datum formaat te zijn (dd-mm-jjjj) OF (dd/mm/jjjj), gelijk aan, of groter dan {0}. ", + "INVALID_DATE_EURO_LONG": "Dient een geldig EURO datum formaat te zijn (dd-mm-jjjj) OF (dd/mm/jjjj). ", + "INVALID_DATE_EURO_LONG_BETWEEN": "Dient een geldig EURO datum formaat te zijn (dd-mm-jjjj) OF (dd/mm/jjjj) tussen {0} en {1}. ", + "INVALID_DATE_EURO_LONG_MAX": "Dient een geldig EURO datum formaat te zijn (dd-mm-jjjj) OF (dd/mm/jjjj), gelijk aan, of kleiner dan {0}. ", + "INVALID_DATE_EURO_LONG_MIN": "Dient een geldig EURO datum formaat te zijn (dd-mm-jjjj) OF (dd/mm/jjjj), gelijk aan, of groter dan {0}. ", + "INVALID_DATE_EURO_SHORT": "Dient een geldig EURO datum formaat te zijn (dd-mm-jj) OF (dd/mm/jj). ", + "INVALID_DATE_EURO_SHORT_BETWEEN": "Dient een geldig EURO datum formaat te zijn (dd-mm-jj) OF (dd/mm/jj) tussen {0} en {1}. ", + "INVALID_DATE_EURO_SHORT_MAX": "Dient een geldig EURO datum formaat te zijn (dd-mm-jj) OF (dd/mm/jj), gelijk aan, of kleiner dan {0}. ", + "INVALID_DATE_EURO_SHORT_MIN": "Dient een geldig EURO datum formaat te zijn (dd-mm-jj) OF (dd/mm/jj), gelijk aan, of groter dan {0}. ", + "INVALID_DATE_ISO": "Dient een geldig ISO datum formaat te zijn (jjjj-mm-dd). ", + "INVALID_DATE_ISO_BETWEEN": "Dient een geldig ISO datum formaat te zijn (jjjj-mm-dd) tussen {0} en {1}. ", + "INVALID_DATE_ISO_MAX": "Dient een geldig ISO datum formaat te zijn (jjjj-mm-dd), gelijk aan, of kleiner dan {0}. ", + "INVALID_DATE_ISO_MIN": "Dient een geldig US datum formaat te zijn (jjjj-mm-dd), gelijk aan, or groter dan {0}. ", + "INVALID_DATE_US": "Dient een geldig US datum formaat te zijn (mm/dd/jjjj) OF (mm-dd-jjjj). ", + "INVALID_DATE_US_BETWEEN": "Dient een geldig US datum formaat te zijn (mm/dd/jjjj) OF (mm-dd-jjjj) tussen {0} en {1}. ", + "INVALID_DATE_US_MAX": "Dient een geldig US datum formaat te zijn (mm/dd/jjjj) OF (mm-dd-jjjj), gelijk aan, of kleiner dan {0}. ", + "INVALID_DATE_US_MIN": "Dient een geldig US datum formaat te zijn (mm/dd/jjjj) OF (mm-dd-jjjj), gelijk aan, of groter dan {0}. ", + "INVALID_DATE_US_LONG": "Dient een geldig US datum formaat te zijn (mm/dd/jjjj) OF (mm-dd-jjjj). ", + "INVALID_DATE_US_LONG_BETWEEN": "Dient een geldig US datum formaat te zijn (mm/dd/jjjj) OF (mm-dd-jjjj) tussen {0} en {1}. ", + "INVALID_DATE_US_LONG_MAX": "Dient een geldig US datum formaat te zijn (mm/dd/jjjj) OF (mm-dd-jjjj), gelijk aan, of kleiner dan {0}. ", + "INVALID_DATE_US_LONG_MIN": "Dient een geldig US datum formaat te zijn (mm/dd/jjjj) OF (mm-dd-jjjj), gelijk aan, of groter dan {0}. ", + "INVALID_DATE_US_SHORT": "Dient een geldig US datum formaat te zijn (mm/dd/jj) OF (mm-dd-jj). ", + "INVALID_DATE_US_SHORT_BETWEEN": "Dient een geldig US datum formaat te zijn (mm/dd/jj) OF (mm-dd-jj) tussen {0} en {1}. ", + "INVALID_DATE_US_SHORT_MAX": "Dient een geldig US datum formaat te zijn (mm/dd/jj) OF (mm-dd-jj), gelijk aan, of kleiner dan {0}. ", + "INVALID_DATE_US_SHORT_MIN": "Dient een geldig US datum formaat te zijn (mm/dd/jj) OF (mm-dd-jj), gelijk aan, of groter dan {0}. ", + "INVALID_DIGITS": "Dient uit {0} digits te bestaan. ", + "INVALID_DIGITS_BETWEEN": "Dient tussen {0} en {1} digits lang te zijn. ", + "INVALID_EMAIL": "Dient een geldig email adres te zijn. ", + "INVALID_EXACT_LEN": "Dient precies {0} karakters lang te zijn. ", + "INVALID_EXACT_NUM": "Dient precies {0} te zijn. ", + "INVALID_FLOAT": "Mag enkel een positieve float waarde zijn (geen integers). ", + "INVALID_FLOAT_SIGNED": "Mag enkel een positieve of negatieve float waarde zijn (geen integers). ", + "INVALID_IBAN": "Dient een geldige IBAN waarde te zijn. ", + "INVALID_IN_LIST": "Dient een waarde uit deze lijst te zijn: ({0}). ", + "INVALID_INPUT_DIFFERENT": "Dient verschillend te zijn van [{1}]. ", + "INVALID_INPUT_MATCH": "Bevestigingswaarde is niet gelijk aan [{1}]. ", + "INVALID_INTEGER": "Dient een positieve integer waarde te zijn. ", + "INVALID_INTEGER_SIGNED": "Dient een positieve of negatieve integer waarde te zijn. ", + "INVALID_IPV4": "Dient een geldig IP te zijn (IPV4). ", + "INVALID_IPV6": "Dient een geldig IP te zijn (IPV6). ", + "INVALID_IPV6_HEX": "Dient een geldig IP te zijn (IPV6 Hex). ", + "INVALID_KEY_CHAR": "Ongeldige KB-waarde voor veld van type 'number'. ", + "INVALID_MAX_CHAR": "Dient groter te zijn dan {0} karakters. ", + "INVALID_MAX_NUM": "Dient een numerische waard te zijn, gelijk aan, of kleiner dan {0}. ", + "INVALID_MIN_CHAR": "Dient ten minste {0} karakters lang te zijn. ", + "INVALID_MIN_NUM": "Dient een numerische waard te zijn, gelijk aan, of groter dan {0}. ", + "INVALID_NOT_IN_LIST": "Waarde mag niet voorkomen in de lijst: ({0}). ", + "INVALID_NUMERIC": "Dient een positief getal te zijn. ", + "INVALID_NUMERIC_SIGNED": "Dient een positief of negatief getal te zijn. ", + "INVALID_PATTERN": "Dient aan volgend formaat te voldoen: {0}. ", + "INVALID_PATTERN_DATA": "Dient aan volgend formaat te voldoen {{data}}. ", + "INVALID_PHONE_US": "Dient een geldig Amerikaans telefoonnummer te zijn, zone nummer inbegrepen. ", + "INVALID_PHONE_INTERNATIONAL": "Dient een geldig Internationaal telefoonnummer te zijn, zone nummer inbegrepen. ", + "INVALID_REQUIRED": "Dit veld is verplicht. ", + "INVALID_URL": "Dient een geldige URL te zijn. ", + "INVALID_TIME": "Dient een geldig tijdsformaat te zijn (hh:mm) OF (hh:mm:ss). ", + "INVALID_CHECKBOX_SELECTED": "De checkbox dient geselecteerd te zijn. ", + + "AREA1": "TextArea: Alphanumerisch + Minimum(15) + Verplicht", + "ERRORS": "Ontbrekende of ongeldige data", + "CHANGE_LANGUAGE": "Taal wijzigen", + "FORM_PREVALIDATED": "Form is pre-gevalideerd", + "INPUT1": "Remote validatie - Typ 'abc' voor een geldig antwoord ", + "INPUT2": "Positief of negatief getal -- input type='number' -- Foutmelding bij niet-numerische karakters ", + "INPUT3": "Floating nummers range (integer uitgesloten) -- tussen_num:x,y OF min_num:x|max_num:y ", + "INPUT4": "Meerdere Validaties + Vrije Regex van Datum Code (JJWW)", + "INPUT5": "Email", + "INPUT6": "URL", + "INPUT7": "IP (IPV4)", + "INPUT8": "Krediet Kaart", + "INPUT9": "Tussen(2,6) karakters", + "INPUT10": "ISO datum (jjjj-mm-dd)", + "INPUT11": "US datum LONG (mm/dd/jjjj)", + "INPUT12": "Tijd (uu:mm OF uu:mm:ss) -- NIET verplicht", + "INPUT13": "AlphaDashSpaces + Verplicht + Minimum(5) karakters -- GEBRUIK: validation-error-to=' '", + "INPUT14": "Alphanumeric + VERPLICHT -- NG-DISABLED", + "INPUT15": "Paswoord", + "INPUT16": "Paswoord Bevestiging", + "INPUT17": "Passwoord is verschillend", + "INPUT18": "Alphanumerisch + Precies(3) + Verplicht -- debounce(3sec)", + "INPUT19": "ISO Datum (jjjj-mm-dd) -- minimum voorwaarde >= 2001-01-01 ", + "INPUT20": "US Datum US SHORT (mm/dd/jj) -- tussen data 12/01/99 en 12/31/15", + "INPUT21": "Kies UIT deze lijst (banana,orange,ice cream,sweet & sour)", + "FIRST_NAME": "Voornaam", + "LAST_NAME": "Achternaam", + "RESET_FORM": "Reset Form", + "SAVE": "Bewaar", + "SELECT1": "Verplicht (select) -- validatie met (blur) EVENT", + "SHOW_VALIDATION_SUMMARY": "Toon Validatie Overzicht" +} + + + + + + + + + + + + + + + + + + + + + + + diff --git a/locales/validation/ro.json b/locales/validation/ro.json new file mode 100644 index 0000000..586f264 --- /dev/null +++ b/locales/validation/ro.json @@ -0,0 +1,105 @@ +{ + "INVALID_ACCEPTED": "Trebuie acceptat. ", + "INVALID_ALPHA": "Poate doar să conţină litere. ", + "INVALID_ALPHA_SPACE": "Poate doar să conţină litere şi spaţii. ", + "INVALID_ALPHA_NUM": "Poate doar să conţină litere şi numere. ", + "INVALID_ALPHA_NUM_SPACE": "Poate doar să conţină litere, spaţii şi numere. ", + "INVALID_ALPHA_DASH": "Poate doar să conţină litere, numere şi cratime. ", + "INVALID_ALPHA_DASH_SPACE": "Poate doar să conţină litere, numere, cratime şi spaţii. ", + "INVALID_BETWEEN_CHAR": "Textul trebuie să fie intre {0} şi {1} charactere în lungime. ", + "INVALID_BETWEEN_NUM": "Trebuie să fie o valoare numerică, între {0} şi {1}. ", + "INVALID_BOOLEAN": "Poate doar să contină o valoare adevarată sau falsă. ", + "INVALID_CREDIT_CARD": "Trebuie să fie un număr de credit card valid. ", + "INVALID_DATE_EURO": "Trebuie să fie un format de dată valid (zz-ll-aaaa) SAU (zz/ll/aaaa). ", + "INVALID_DATE_EURO_BETWEEN": "Este nevoie de un format de dată valid (zz-ll-aaaa) SAU (zz/ll/aaaa) între {0} şi {1}. ", + "INVALID_DATE_EURO_MAX": "Este nevoie de un format de dată valid (zz-ll-aaaa) SAU (zz/ll/aaaa), egală cu, sau mai mică decât {0}. ", + "INVALID_DATE_EURO_MIN": "Este nevoie de un format de dată valid (zz-ll-aaaa) SAU (zz/ll/aaaa), egală cu, sau mai mare decât {0}. ", + "INVALID_DATE_EURO_LONG": "Trebuie să fie un format de dată valid (zz-ll-aaaa) SAU (zz/ll/aaaa). ", + "INVALID_DATE_EURO_LONG_BETWEEN": "Este nevoie de un format de dată valid (zz-ll-aaaa) SAU (zz/ll/aaaa) între {0} şi {1}. ", + "INVALID_DATE_EURO_LONG_MAX": "Este nevoie de un format de dată valid (zz-ll-aaaa) SAU (zz/ll/aaaa), egală cu, sau mai mică decât {0}. ", + "INVALID_DATE_EURO_LONG_MIN": "Este nevoie de un format de dată valid (zz-ll-aaaa) SAU (zz/ll/aaaa), egală cu, sau mai mare decât {0}. ", + "INVALID_DATE_EURO_SHORT": "Trebuie să fie un format de dată valid (zz-ll-aa) SAU (zz/ll/aa). ", + "INVALID_DATE_EURO_SHORT_BETWEEN": "Este nevoie de un format de dată valid (zz-ll-aa) SAU (zz/ll/aa) între {0} şi {1}. ", + "INVALID_DATE_EURO_SHORT_MAX": "Este nevoie de un format de dată valid (zz-ll-aa) SAU (zz/ll/aa), egală cu, sau mai mică decât {0}. ", + "INVALID_DATE_EURO_SHORT_MIN": "Este nevoie de un format de dată valid (zz-ll-aa) SAU (zz/ll/aa), egală cu, sau mai mare decât {0}. ", + "INVALID_DATE_ISO": "Trebuie să fie un format de dată valid (aaaa-ll-zz). ", + "INVALID_DATE_ISO_BETWEEN": "Este nevoie de un format de dată valid (aaaa-ll-zz) între {0} si {1}. ", + "INVALID_DATE_ISO_MAX": "Este nevoie de un format de dată valid (aaaa-ll-zz), egală cu, sau mai mică decat {0}. ", + "INVALID_DATE_ISO_MIN": "Este nevoie de un format de dată valid (aaaa-ll-zz), egală cu, sau mai mare decat {0}. ", + "INVALID_DATE_US": "Trebuie sa fie un format de dată valid (ll/zz/aaaa) SAU (ll-zz-aaaa). ", + "INVALID_DATE_US_BETWEEN": "Este nevoie de un format de dată valid (ll/zz/aaaa) SAU (ll-zz-aaaa) între {0} si {1}. ", + "INVALID_DATE_US_MAX": "Este nevoie de un format de dată valid (ll/zz/aaaa) SAU (ll-zz-aaaa), egală cu, sau mai mică decât {0}. ", + "INVALID_DATE_US_MIN": "Este nevoie de un format de dată valid (ll/zz/aaaa) SAU (ll-zz-aaaa), egală cu, sau mai mare decât {0}. ", + "INVALID_DATE_US_LONG": "Trebuie sa fie un format de dată valid (ll/zz/aaaa) SAU (ll-zz-aaaa). ", + "INVALID_DATE_US_LONG_BETWEEN": "Este nevoie de un format de dată valid (ll/zz/aaaa) SAU (ll-zz-aaaa) intre {0} si {1}. ", + "INVALID_DATE_US_LONG_MAX": "Este nevoie de un format de dată valid (ll/zz/aaaa) SAU (ll-zz-aaaa), egală cu, sau mai mică decât {0}. ", + "INVALID_DATE_US_LONG_MIN": "Este nevoie de un format de dată valid (ll/zz/aaaa) SAU (ll-zz-aaaa), egală cu, sau mai mare decât {0}. ", + "INVALID_DATE_US_SHORT": "Trebuie sa fie un format de dată valid (ll/zz/yy) SAU (ll-zz-aa). ", + "INVALID_DATE_US_SHORT_BETWEEN": "Este nevoie de un format de dată valid (ll/zz/yy) SAU (ll-zz-aa) între {0} si {1}. ", + "INVALID_DATE_US_SHORT_MAX": "Este nevoie de un format de dată valid (ll/zz/yy) SAU (ll-zz-aa), egală cu, sau mai mică decât {0}. ", + "INVALID_DATE_US_SHORT_MIN": "Este nevoie de un format de dată valid (ll/zz/yy) SAU (ll-zz-aa), egală cu, sau mai mare decât {0}. ", + "INVALID_DIGITS": "Trebuie să fie {0} cifre. ", + "INVALID_DIGITS_BETWEEN": "Trebuie să fie intre {0} şi {1} cifre. ", + "INVALID_EMAIL": "Trebuie să fie un e-mail valid. ", + "INVALID_EXACT_LEN": "Trebuie să aibă o lungime exactă de {0} charactere. ", + "INVALID_EXACT_NUM": "Trebuie să fie exact {0}. ", + "INVALID_FLOAT": "Poate doar să contină o valoare pozitivă de numere reale (numere intregi excluse). ", + "INVALID_FLOAT_SIGNED": "Poate doar să contina o valoare pozitivă sau negativă de numere reale (numere intregi excluse). ", + "INVALID_IBAN": "Trebuie să fie un IBAN valid. ", + "INVALID_IN_LIST": "Trebuie să fie o alegere din această listă: ({0}). ", + "INVALID_INPUT_DIFFERENT": "Conţinutul trebuie să fie diferit faţă de acest conţinut [{1}]. ", + "INVALID_INPUT_MATCH": "Conţinutul de confirmare nu corespunde conţinutului specificat [{1}]. ", + "INVALID_INTEGER": "Trebuie să fie un număr pozitiv. ", + "INVALID_INTEGER_SIGNED": "Trebuie să fie un număr pozitiv sau negativ. ", + "INVALID_IPV4": "Trebuie să fie un IP valid (IPV4). ", + "INVALID_IPV6": "Trebuie să fie un IP valid (IPV6). ", + "INVALID_IPV6_HEX": "Trebuie să fie un IP valid (IPV6 Hex). ", + "INVALID_KEY_CHAR": "Textul de intrare este invalid, trebuie să fie de tip 'număr'. ", + "INVALID_MAX_CHAR": "Nu trebuie să fie mai mult decât {0} charactere. ", + "INVALID_MAX_NUM": "Este nevoie de o valoare numerică, egală cu, sau mai mică decat {0}. ", + "INVALID_MIN_CHAR": "Trebuie să fie măcar {0} charactere. ", + "INVALID_MIN_NUM": "Este nevoie de o valoare numerică, egală cu, sau mai mare decat {0}. ", + "INVALID_NOT_IN_LIST": "Trebuie să fie o alegere înafara aceastei liste: ({0}). ", + "INVALID_NUMERIC": "Trebuie să fie un număr pozitiv. ", + "INVALID_NUMERIC_SIGNED": "Trebuie să fie un număr pozitiv sau negativ. ", + "INVALID_PATTERN": "Trebuie să urmeze acest format: {0}. ", + "INVALID_PATTERN_DATA": "Trebuie să urmeze acest format {{data}}. ", + "INVALID_PHONE_US": "Trebuie să fie un număr de telefon valid şi trebuie să includă prefixul zonei. ", + "INVALID_PHONE_INTERNATIONAL": "Trebuie să fie un număr de telefon internaţional valid. ", + "INVALID_REQUIRED": "Conţinutul este necesar. ", + "INVALID_URL": "Trebuie să fie un URL valid. ", + "INVALID_TIME": "Trebuie să fie un format de timp valid (oo:mm) SAU (oo:mm:ss). ", + "INVALID_CHECKBOX_SELECTED": "Caseta de bifat trebuie să fie selectată. ", + + "AREA1": "Textul trebuie să fie: Alfabetic + Minim (15) + Necesar", + "ERRORS": "Erori", + "CHANGE_LANGUAGE": "Schimbaţi limba", + "FORM_PREVALIDATED": "Forma este pre-validată", + "INPUT1": "Stergeţi validarea - Scrieţi 'abc' pentru un răspuns valid ", + "INPUT2": "Număr pozitiv sau negativ -- input type='number' -- Eroare la caracterele nenumerice ", + "INPUT3": "Raza numerelor reale (numere intregi excluse) -- between_num:x,y SAU min_num:x|max_num:y ", + "INPUT4": "Validaţii multiple + Cod de dată Regex Personalizat (AASS)", + "INPUT5": "E-mail", + "INPUT6": "URL", + "INPUT7": "IP (IPV4)", + "INPUT8": "Credit Card", + "INPUT9": "Între (2,6) Caractere", + "INPUT10": "Date ISO (aaaa-ll-zz)", + "INPUT11": "Date US LONG (ll/zz/aaaa)", + "INPUT12": "Timp (oo:mm SAU oo:mm:ss) -- Nu este necesar", + "INPUT13": "AlphaDashSpaces + Nececesar + Minimum(5) Caractere -- TREBUIE FOLOSIT: validation-error-to=' '", + "INPUT14": "Alphanumerice + Necesar -- NG-DISABLED", + "INPUT15": "Parola", + "INPUT16": "Confirmarea parolei", + "INPUT17": "Parola diferita", + "INPUT18": "Alphanumerice + Exact(3) + Necesar -- debounce(3sec)", + "INPUT19": "Date ISO (aaaa-ll-zz) -- condiţii minime >= 2001-01-01 ", + "INPUT20": "Date US SHORT (ll/zz/aa) -- între datele 12/01/99 şi 12/31/15", + "INPUT21": "Alegeţi din această listă (banana,orange,ice cream,sweet & sour)", + "FIRST_NAME": "Numele", + "LAST_NAME": "Numele de familie", + "RESET_FORM": "Formă de Resetare", + "SAVE": "Salvare", + "SELECT1": "Necesită (select) -- validare cu (blur) EVENT", + "SHOW_VALIDATION_SUMMARY": "Afişare sumar de validare" +} \ No newline at end of file From 87e229d08ac35e7f11fb7a9aa8be39fded2ea088 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Mon, 3 Oct 2016 20:52:16 -0400 Subject: [PATCH 11/60] Add Dutch and Romanian #134 --- bower.json | 2 +- dist/angular-validation.min.js | 4 ++-- package.json | 2 +- readme.md | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index a9b384a..ad285f1 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.6", + "version": "1.5.7", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 2c97c4a..c2d773b 100644 --- a/dist/angular-validation.min.js +++ b/dist/angular-validation.min.js @@ -2,9 +2,9 @@ * Angular-Validation Directive and Service (ghiscoding) * http://github.com/ghiscoding/angular-validation * @author: Ghislain B. - * @version: 1.5.6 + * @version: 1.5.7 * @license: MIT - * @build: Sat Sep 24 2016 00:49:05 GMT-0400 (Eastern Daylight Time) + * @build: Mon Oct 03 2016 20:51:48 GMT-0400 (Eastern Daylight Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(w){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i,0);A&&$.runValidationCallbackOnPromise(n,A)}}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);A&&$.runValidationCallbackOnPromise(i,A)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,A=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,w=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i);A&&$.runValidationCallbackOnPromise(n,A)}}})}}}]); angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function i(e,t,r){if("undefined"!=typeof e&&null!=e){var i=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),n=E(i,e),o=w(z,"field",i);if(o>=0&&""===t)z.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:i,friendlyName:s,message:t,formName:n?n.$name:null};o>=0?z[o]=l:z.push(l)}if(e.scope.$validationSummary=z,n&&(n.$validationSummary=V(z,"formName",n.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,n&&n.$name)){var d=n.$name.indexOf(".")>=0?n.$name.split(".")[1]:n.$name,u=_.controllerAs[d]?_.controllerAs[d]:e.elm.controller()[d];u&&(u.$validationSummary=V(z,"formName",n.$name))}return z}}function n(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var i=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!i||i.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var n=i[1],o=i[2]?i[2].replace(/\|(.*)/,""):"",s=n.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+n,"pattern")}else if(a.indexOf("regex:")>=0){var i=a.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 d=i[1].split(":=");t={message:d[0],pattern:d[1]},a=a.replace(i[0],"regex:")}var u=a.split("|");if(u){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=u.length;p=0,g=[];f?(g=u[p].substring(0,c-1).split(":"),g.push(u[p].substring(c))):g=u[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return A(B,"fieldName",e)}function s(e){return e?V(B,"formName",e):B}function l(){return _}function d(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function u(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=w(B,"fieldName",e);t>=0&&B.splice(t,1)}function c(e,t){var a=this,r=E(e,a),i=t||z,n=w(i,"field",e);if(n>=0&&i.splice(n,1),n=w(z,"field",e),n>=0&&z.splice(n,1),a.scope.$validationSummary=z,r&&(r.$validationSummary=V(z,"formName",r.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;_.controllerAs[o]&&(_.controllerAs[o].$validationSummary=V(z,"formName",r.$name))}return z}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){_.displayOnlyLastErrorMsg=e}function y(e){var t=this;return _=p(_,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var i=t&&t.elm?t.elm:r.elm,n=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof n||null===n){var o=i?i.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=n.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),d=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var u=r.validatorAttrs.validationErrorTo.charAt(0),p="."===u||"#"===u?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;d=angular.element(document.querySelector(p))}d&&0!==d.length||(d=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!_.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?d.length>0?d.html(s):i.after('
'+s+"
"):d.html("")}function b(e,t){var r,n=this,s=!0,l=!0,d=0,u={message:""};"undefined"==typeof e&&(e="");for(var p=n.ctrl&&n.ctrl.$name?n.ctrl.$name:n.attrs&&n.attrs.name?n.attrs.name:n.elm.attr("name"),m=o(p),c=n.validatorAttrs.rules||n.validatorAttrs.validation,f=0,g=n.validators.length;f0&&(o=i.altText.replace("alt=",""));var d=a(o);e.translatePromise=d,e.validator=i,d.then(function(a){u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+(i&&i.params?String.format(a,i.params):a):u.message+=s+(i&&i.params?String.format(a,i.params):a),O(n,e,u.message,l,t)})["catch"](function(a){if(!(i.altText&&i.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+o:u.message+=s+o,O(n,e,u.message,l,t)})}(m,s,r)),s&&d++,n.validRequireHowMany==d&&s){l=!0;break}}return s&&(i(n,""),n.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,i){var n=t.name?t.name:e.attr("name"),o=E(n,{scope:i}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:n,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:i,isValid:!1,message:"",formName:o?o.$name:null},d=w(B,"fieldName",e.attr("name"));return d>=0?B[d]=l:B.push(l),B}function O(e,t,a,r,n){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(_.preValidateValidationSummary||"undefined"==typeof _.preValidateValidationSummary||n)&&i(t,a),(e.validatorAttrs.preValidateFormElements||_.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),n&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&i(t,"")}function S(e){return e.typingLimit=I,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):_&&_.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(_.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:_.validRequireHowMany,K=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):_.validateOnEmpty,e}function A(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(n){var o=n?n.getAttribute("name"):null;if(o){var s={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(_&&_.controllerAs&&o.indexOf(".")>=0){var l=o.split(".");return t.scope[l[0]][l[1]]=s}return t.scope[o]=s}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,i=0,n=r.length;i8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),l=i[0],s=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),i=q(a,r),o=i[0],s=i[1],l=i[2],n=e.length>10?e.substring(11).split(":"):null}var d=n&&3===n.length?n[0]:0,u=n&&3===n.length?n[1]:0,p=n&&3===n.length?n[2]:0;return new Date(o,s-1,l,d,u,p)}function q(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function F(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function k(){return this.replace(/^\s+|\s+$/g,"")}function L(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function M(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function C(e,t,a){var r=!0,i=r=!1;if(e instanceof Date)i=!0;else{var n=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&n.test(e)}if(i){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),d=T(t.params[1],o).getTime(),u=F(t.condition[0],s,l),p=F(t.condition[1],s,d);r=u&&p}else{var m=T(t.params[0],o).getTime();r=F(t.condition,s,m)}}return r}function U(e,t){var a=!0;if(2==t.params.length){var r=F(t.condition[0],parseFloat(e),parseFloat(t.params[0])),i=F(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&i}else a=F(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function P(e,a,r,i,n,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",d="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||K){var u=a.params[0],p=f(r,u);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw d;s=!!p.isValid}if(s===!1?(i.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,i,e,!1,n)})):s===!0&&(i.isValid=!0,O(r,i,"",!0,n)),"undefined"==typeof p)throw d}return s}function j(e,t,r,i){var n=!0,s=t.params[0],l=r.scope.$eval(s),d=angular.element(document.querySelector('[name="'+s+'"]')),u=t,p=r.ctrl,m=o(r.ctrl.$name);return n=F(t.condition,e,l)&&!!e,d&&d.attr("friendly-name")?t.params[1]=d.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var n=F(u.condition,p.$viewValue,e);if(e!==t){if(n)O(r,m,"",!0,!0);else{m.isValid=!1;var o=u.message;u.altText&&u.altText.length>0&&(o=u.altText.replace("alt=","")),a(o).then(function(e){var t=_.errorMessageSeparator||" ";i.message=t+(u&&u.params?String.format(e,u.params):e),O(r,m,i.message,n,!0)})}p.$setValidity("validation",n)}},!0),n}function G(e,t,a,r,i,n){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&i||K){a.ctrl.$processing=!0;var d=t.params[0],u=f(a,d);if(J.length>1)for(;J.length>0;){var p=J.pop();"function"==typeof p.abort&&p.abort()}if(J.push(u),!u||"function"!=typeof u.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){u.then(function(t){t=t.data||t,J.pop(),a.ctrl.$processing=!1;var d=n.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,d+=t.message||e," "===d)throw s;O(a,r,d,!1,i)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,i))})}(t.altText)}return o}function H(e,t,a,r){var i=!0,n=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(n))i=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())i=!1;else{var o=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return i}function D(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var I=1e3,B=[],_={resetGlobalOptionsOnRouteChange:!0},J=[],z=[],K=!1;e.$on("$routeChangeStart",function(e,t,a){_.resetGlobalOptionsOnRouteChange&&(_={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},B=[],z=[])});var Y=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=I,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(_=e.$validationOptions),e&&(_.isolatedScope||_.scope)&&(this.scope=_.isolatedScope||_.scope,_=p(e.$validationOptions,_)),"undefined"==typeof _.resetGlobalOptionsOnRouteChange&&(_.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return Y.prototype.addToValidationSummary=i,Y.prototype.arrayFindObject=A,Y.prototype.defineValidation=n,Y.prototype.getFormElementByName=o,Y.prototype.getFormElements=s,Y.prototype.getGlobalOptions=l,Y.prototype.isFieldRequired=u,Y.prototype.initialize=d,Y.prototype.mergeObjects=p,Y.prototype.parseBool=N,Y.prototype.removeFromValidationSummary=c,Y.prototype.removeFromFormElementObjectList=m,Y.prototype.runValidationCallbackOnPromise=g,Y.prototype.setDisplayOnlyLastErrorMsg=v,Y.prototype.setGlobalOptions=y,Y.prototype.updateErrorMsg=h,Y.prototype.validate=b,String.prototype.trim=k,String.prototype.format=L,String.format=M,Y}]); diff --git a/package.json b/package.json index 0d7382c..5598eac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.6", + "version": "1.5.7", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": "app.js", diff --git a/readme.md b/readme.md index c62430f..eebaf13 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ #Angular Validation (Directive / Service) -`Version: 1.5.6` +`Version: 1.5.7` ### Forms Validation with Angular made easy! ##### (Concept comes from the amazing Laravel) From fcf437f789587e1c7822dfd8c7d6a378c78bbadd Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Mon, 3 Oct 2016 21:04:00 -0400 Subject: [PATCH 12/60] Update changelog --- changelog.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.txt b/changelog.txt index ac01b91..6257022 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ Angular-Validation change logs +1.5.7 (2016-10-03) Add Dutch and Romanian #134 +1.5.6 (2016-09-24) Dates validator now checks for leap year & full date calendar, fix #130 +1.5.5 (2016-09-01) If translation isn't loading & working correctly, it should throw an error. 1.5.4 (2016-07-29) Fixed an issue with 3rd party validation not triggering a $scope.$watch. Also added new international phone validation (issue #125). 1.5.3 (2016-07-20) Add C# validation annotation, (for example: maxLen => maxLength) 1.5.2 (2016-06-14) Fixed #121 Alternate text containing the char ":" was causing unexpected displayed message. From 7db6c92a6a2d044ea527b32654ab2e22c23f447d Mon Sep 17 00:00:00 2001 From: Gusi Date: Fri, 14 Oct 2016 10:13:06 +0200 Subject: [PATCH 13/60] Updated main entry at package.json to work with WebPack --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5598eac..d42d95b 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.5.7", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", - "main": "app.js", + "main": "dist/angular-validation.min", "dependencies": {}, "devDependencies": { "del": "^1.2.1", From d6c626b91f8d018df7a54aa371de9ff3127fc0e8 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Fri, 14 Oct 2016 12:54:29 -0400 Subject: [PATCH 14/60] Bump version for package.json to work with WebPack Forgot to bump version --- bower.json | 2 +- changelog.txt | 1 + dist/angular-validation.min.js | 4 ++-- package.json | 2 +- readme.md | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index ad285f1..8c65c8c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.7", + "version": "1.5.9", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index 6257022..ac7a41a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.9 (2016-10-14) Updated main entry at package.json to work with WebPack, issue #128 1.5.7 (2016-10-03) Add Dutch and Romanian #134 1.5.6 (2016-09-24) Dates validator now checks for leap year & full date calendar, fix #130 1.5.5 (2016-09-01) If translation isn't loading & working correctly, it should throw an error. diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index c2d773b..0e5faaa 100644 --- a/dist/angular-validation.min.js +++ b/dist/angular-validation.min.js @@ -2,9 +2,9 @@ * Angular-Validation Directive and Service (ghiscoding) * http://github.com/ghiscoding/angular-validation * @author: Ghislain B. - * @version: 1.5.7 + * @version: 1.5.9 * @license: MIT - * @build: Mon Oct 03 2016 20:51:48 GMT-0400 (Eastern Daylight Time) + * @build: Mon Oct 14 2016 20:51:48 GMT-0400 (Eastern Daylight Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(w){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i,0);A&&$.runValidationCallbackOnPromise(n,A)}}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);A&&$.runValidationCallbackOnPromise(i,A)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,A=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,w=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i);A&&$.runValidationCallbackOnPromise(n,A)}}})}}}]); angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function i(e,t,r){if("undefined"!=typeof e&&null!=e){var i=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),n=E(i,e),o=w(z,"field",i);if(o>=0&&""===t)z.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:i,friendlyName:s,message:t,formName:n?n.$name:null};o>=0?z[o]=l:z.push(l)}if(e.scope.$validationSummary=z,n&&(n.$validationSummary=V(z,"formName",n.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,n&&n.$name)){var d=n.$name.indexOf(".")>=0?n.$name.split(".")[1]:n.$name,u=_.controllerAs[d]?_.controllerAs[d]:e.elm.controller()[d];u&&(u.$validationSummary=V(z,"formName",n.$name))}return z}}function n(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var i=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!i||i.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var n=i[1],o=i[2]?i[2].replace(/\|(.*)/,""):"",s=n.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+n,"pattern")}else if(a.indexOf("regex:")>=0){var i=a.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 d=i[1].split(":=");t={message:d[0],pattern:d[1]},a=a.replace(i[0],"regex:")}var u=a.split("|");if(u){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=u.length;p=0,g=[];f?(g=u[p].substring(0,c-1).split(":"),g.push(u[p].substring(c))):g=u[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return A(B,"fieldName",e)}function s(e){return e?V(B,"formName",e):B}function l(){return _}function d(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function u(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=w(B,"fieldName",e);t>=0&&B.splice(t,1)}function c(e,t){var a=this,r=E(e,a),i=t||z,n=w(i,"field",e);if(n>=0&&i.splice(n,1),n=w(z,"field",e),n>=0&&z.splice(n,1),a.scope.$validationSummary=z,r&&(r.$validationSummary=V(z,"formName",r.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;_.controllerAs[o]&&(_.controllerAs[o].$validationSummary=V(z,"formName",r.$name))}return z}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){_.displayOnlyLastErrorMsg=e}function y(e){var t=this;return _=p(_,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var i=t&&t.elm?t.elm:r.elm,n=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof n||null===n){var o=i?i.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=n.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),d=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var u=r.validatorAttrs.validationErrorTo.charAt(0),p="."===u||"#"===u?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;d=angular.element(document.querySelector(p))}d&&0!==d.length||(d=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!_.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?d.length>0?d.html(s):i.after('
'+s+"
"):d.html("")}function b(e,t){var r,n=this,s=!0,l=!0,d=0,u={message:""};"undefined"==typeof e&&(e="");for(var p=n.ctrl&&n.ctrl.$name?n.ctrl.$name:n.attrs&&n.attrs.name?n.attrs.name:n.elm.attr("name"),m=o(p),c=n.validatorAttrs.rules||n.validatorAttrs.validation,f=0,g=n.validators.length;f0&&(o=i.altText.replace("alt=",""));var d=a(o);e.translatePromise=d,e.validator=i,d.then(function(a){u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+(i&&i.params?String.format(a,i.params):a):u.message+=s+(i&&i.params?String.format(a,i.params):a),O(n,e,u.message,l,t)})["catch"](function(a){if(!(i.altText&&i.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+o:u.message+=s+o,O(n,e,u.message,l,t)})}(m,s,r)),s&&d++,n.validRequireHowMany==d&&s){l=!0;break}}return s&&(i(n,""),n.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,i){var n=t.name?t.name:e.attr("name"),o=E(n,{scope:i}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:n,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:i,isValid:!1,message:"",formName:o?o.$name:null},d=w(B,"fieldName",e.attr("name"));return d>=0?B[d]=l:B.push(l),B}function O(e,t,a,r,n){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(_.preValidateValidationSummary||"undefined"==typeof _.preValidateValidationSummary||n)&&i(t,a),(e.validatorAttrs.preValidateFormElements||_.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),n&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&i(t,"")}function S(e){return e.typingLimit=I,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):_&&_.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(_.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:_.validRequireHowMany,K=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):_.validateOnEmpty,e}function A(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(n){var o=n?n.getAttribute("name"):null;if(o){var s={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(_&&_.controllerAs&&o.indexOf(".")>=0){var l=o.split(".");return t.scope[l[0]][l[1]]=s}return t.scope[o]=s}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,i=0,n=r.length;i8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),l=i[0],s=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),i=q(a,r),o=i[0],s=i[1],l=i[2],n=e.length>10?e.substring(11).split(":"):null}var d=n&&3===n.length?n[0]:0,u=n&&3===n.length?n[1]:0,p=n&&3===n.length?n[2]:0;return new Date(o,s-1,l,d,u,p)}function q(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function F(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function k(){return this.replace(/^\s+|\s+$/g,"")}function L(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function M(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function C(e,t,a){var r=!0,i=r=!1;if(e instanceof Date)i=!0;else{var n=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&n.test(e)}if(i){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),d=T(t.params[1],o).getTime(),u=F(t.condition[0],s,l),p=F(t.condition[1],s,d);r=u&&p}else{var m=T(t.params[0],o).getTime();r=F(t.condition,s,m)}}return r}function U(e,t){var a=!0;if(2==t.params.length){var r=F(t.condition[0],parseFloat(e),parseFloat(t.params[0])),i=F(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&i}else a=F(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function P(e,a,r,i,n,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",d="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||K){var u=a.params[0],p=f(r,u);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw d;s=!!p.isValid}if(s===!1?(i.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,i,e,!1,n)})):s===!0&&(i.isValid=!0,O(r,i,"",!0,n)),"undefined"==typeof p)throw d}return s}function j(e,t,r,i){var n=!0,s=t.params[0],l=r.scope.$eval(s),d=angular.element(document.querySelector('[name="'+s+'"]')),u=t,p=r.ctrl,m=o(r.ctrl.$name);return n=F(t.condition,e,l)&&!!e,d&&d.attr("friendly-name")?t.params[1]=d.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var n=F(u.condition,p.$viewValue,e);if(e!==t){if(n)O(r,m,"",!0,!0);else{m.isValid=!1;var o=u.message;u.altText&&u.altText.length>0&&(o=u.altText.replace("alt=","")),a(o).then(function(e){var t=_.errorMessageSeparator||" ";i.message=t+(u&&u.params?String.format(e,u.params):e),O(r,m,i.message,n,!0)})}p.$setValidity("validation",n)}},!0),n}function G(e,t,a,r,i,n){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&i||K){a.ctrl.$processing=!0;var d=t.params[0],u=f(a,d);if(J.length>1)for(;J.length>0;){var p=J.pop();"function"==typeof p.abort&&p.abort()}if(J.push(u),!u||"function"!=typeof u.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){u.then(function(t){t=t.data||t,J.pop(),a.ctrl.$processing=!1;var d=n.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,d+=t.message||e," "===d)throw s;O(a,r,d,!1,i)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,i))})}(t.altText)}return o}function H(e,t,a,r){var i=!0,n=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(n))i=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())i=!1;else{var o=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return i}function D(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var I=1e3,B=[],_={resetGlobalOptionsOnRouteChange:!0},J=[],z=[],K=!1;e.$on("$routeChangeStart",function(e,t,a){_.resetGlobalOptionsOnRouteChange&&(_={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},B=[],z=[])});var Y=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=I,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(_=e.$validationOptions),e&&(_.isolatedScope||_.scope)&&(this.scope=_.isolatedScope||_.scope,_=p(e.$validationOptions,_)),"undefined"==typeof _.resetGlobalOptionsOnRouteChange&&(_.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return Y.prototype.addToValidationSummary=i,Y.prototype.arrayFindObject=A,Y.prototype.defineValidation=n,Y.prototype.getFormElementByName=o,Y.prototype.getFormElements=s,Y.prototype.getGlobalOptions=l,Y.prototype.isFieldRequired=u,Y.prototype.initialize=d,Y.prototype.mergeObjects=p,Y.prototype.parseBool=N,Y.prototype.removeFromValidationSummary=c,Y.prototype.removeFromFormElementObjectList=m,Y.prototype.runValidationCallbackOnPromise=g,Y.prototype.setDisplayOnlyLastErrorMsg=v,Y.prototype.setGlobalOptions=y,Y.prototype.updateErrorMsg=h,Y.prototype.validate=b,String.prototype.trim=k,String.prototype.format=L,String.format=M,Y}]); diff --git a/package.json b/package.json index d42d95b..d06342e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.7", + "version": "1.5.9", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": "dist/angular-validation.min", diff --git a/readme.md b/readme.md index eebaf13..b18af44 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ #Angular Validation (Directive / Service) -`Version: 1.5.7` +`Version: 1.5.9` ### Forms Validation with Angular made easy! ##### (Concept comes from the amazing Laravel) From ffe2fa61fe1e604bc3463f88fcd41f2403a40617 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Fri, 18 Nov 2016 18:39:57 -0500 Subject: [PATCH 15/60] Add MIT license txt file --- MIT-license.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 MIT-license.txt diff --git a/MIT-license.txt b/MIT-license.txt new file mode 100644 index 0000000..05d007e --- /dev/null +++ b/MIT-license.txt @@ -0,0 +1,20 @@ +Copyright (c) 2016, https://github.com/ghiscoding/angular-validation + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file From bd3dd6e10599510da1873d168eff357aba0358fd Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Wed, 14 Dec 2016 00:42:23 -0500 Subject: [PATCH 16/60] include a watch for UI Router --- bower.json | 2 +- dist/angular-validation.min.js | 6 ++--- gulpfile.js | 14 ++++++++++++ package.json | 5 +++- protractor/conf.js | 1 + readme.md | 2 +- src/validation-common.js | 42 +++++++++++++++++++++------------- 7 files changed, 50 insertions(+), 22 deletions(-) diff --git a/bower.json b/bower.json index 8c65c8c..766e930 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.9", + "version": "1.5.10", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 0e5faaa..d772c97 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.5.9 + * @version: 1.5.10 * @license: MIT - * @build: Mon Oct 14 2016 20:51:48 GMT-0400 (Eastern Daylight Time) + * @build: Wed Dec 14 2016 00:20:38 GMT-0500 (Eastern Standard Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(w){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i,0);A&&$.runValidationCallbackOnPromise(n,A)}}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);A&&$.runValidationCallbackOnPromise(i,A)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,A=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,w=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i);A&&$.runValidationCallbackOnPromise(n,A)}}})}}}]); -angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function i(e,t,r){if("undefined"!=typeof e&&null!=e){var i=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),n=E(i,e),o=w(z,"field",i);if(o>=0&&""===t)z.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:i,friendlyName:s,message:t,formName:n?n.$name:null};o>=0?z[o]=l:z.push(l)}if(e.scope.$validationSummary=z,n&&(n.$validationSummary=V(z,"formName",n.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,n&&n.$name)){var d=n.$name.indexOf(".")>=0?n.$name.split(".")[1]:n.$name,u=_.controllerAs[d]?_.controllerAs[d]:e.elm.controller()[d];u&&(u.$validationSummary=V(z,"formName",n.$name))}return z}}function n(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var i=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!i||i.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var n=i[1],o=i[2]?i[2].replace(/\|(.*)/,""):"",s=n.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+n,"pattern")}else if(a.indexOf("regex:")>=0){var i=a.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 d=i[1].split(":=");t={message:d[0],pattern:d[1]},a=a.replace(i[0],"regex:")}var u=a.split("|");if(u){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=u.length;p=0,g=[];f?(g=u[p].substring(0,c-1).split(":"),g.push(u[p].substring(c))):g=u[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return A(B,"fieldName",e)}function s(e){return e?V(B,"formName",e):B}function l(){return _}function d(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function u(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=w(B,"fieldName",e);t>=0&&B.splice(t,1)}function c(e,t){var a=this,r=E(e,a),i=t||z,n=w(i,"field",e);if(n>=0&&i.splice(n,1),n=w(z,"field",e),n>=0&&z.splice(n,1),a.scope.$validationSummary=z,r&&(r.$validationSummary=V(z,"formName",r.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;_.controllerAs[o]&&(_.controllerAs[o].$validationSummary=V(z,"formName",r.$name))}return z}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){_.displayOnlyLastErrorMsg=e}function y(e){var t=this;return _=p(_,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var i=t&&t.elm?t.elm:r.elm,n=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof n||null===n){var o=i?i.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=n.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),d=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var u=r.validatorAttrs.validationErrorTo.charAt(0),p="."===u||"#"===u?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;d=angular.element(document.querySelector(p))}d&&0!==d.length||(d=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!_.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?d.length>0?d.html(s):i.after('
'+s+"
"):d.html("")}function b(e,t){var r,n=this,s=!0,l=!0,d=0,u={message:""};"undefined"==typeof e&&(e="");for(var p=n.ctrl&&n.ctrl.$name?n.ctrl.$name:n.attrs&&n.attrs.name?n.attrs.name:n.elm.attr("name"),m=o(p),c=n.validatorAttrs.rules||n.validatorAttrs.validation,f=0,g=n.validators.length;f0&&(o=i.altText.replace("alt=",""));var d=a(o);e.translatePromise=d,e.validator=i,d.then(function(a){u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+(i&&i.params?String.format(a,i.params):a):u.message+=s+(i&&i.params?String.format(a,i.params):a),O(n,e,u.message,l,t)})["catch"](function(a){if(!(i.altText&&i.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+o:u.message+=s+o,O(n,e,u.message,l,t)})}(m,s,r)),s&&d++,n.validRequireHowMany==d&&s){l=!0;break}}return s&&(i(n,""),n.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,i){var n=t.name?t.name:e.attr("name"),o=E(n,{scope:i}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:n,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:i,isValid:!1,message:"",formName:o?o.$name:null},d=w(B,"fieldName",e.attr("name"));return d>=0?B[d]=l:B.push(l),B}function O(e,t,a,r,n){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(_.preValidateValidationSummary||"undefined"==typeof _.preValidateValidationSummary||n)&&i(t,a),(e.validatorAttrs.preValidateFormElements||_.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),n&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&i(t,"")}function S(e){return e.typingLimit=I,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):_&&_.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(_.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:_.validRequireHowMany,K=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):_.validateOnEmpty,e}function A(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(n){var o=n?n.getAttribute("name"):null;if(o){var s={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(_&&_.controllerAs&&o.indexOf(".")>=0){var l=o.split(".");return t.scope[l[0]][l[1]]=s}return t.scope[o]=s}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,i=0,n=r.length;i8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),l=i[0],s=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),i=q(a,r),o=i[0],s=i[1],l=i[2],n=e.length>10?e.substring(11).split(":"):null}var d=n&&3===n.length?n[0]:0,u=n&&3===n.length?n[1]:0,p=n&&3===n.length?n[2]:0;return new Date(o,s-1,l,d,u,p)}function q(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function F(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function k(){return this.replace(/^\s+|\s+$/g,"")}function L(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function M(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function C(e,t,a){var r=!0,i=r=!1;if(e instanceof Date)i=!0;else{var n=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&n.test(e)}if(i){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),d=T(t.params[1],o).getTime(),u=F(t.condition[0],s,l),p=F(t.condition[1],s,d);r=u&&p}else{var m=T(t.params[0],o).getTime();r=F(t.condition,s,m)}}return r}function U(e,t){var a=!0;if(2==t.params.length){var r=F(t.condition[0],parseFloat(e),parseFloat(t.params[0])),i=F(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&i}else a=F(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function P(e,a,r,i,n,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",d="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||K){var u=a.params[0],p=f(r,u);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw d;s=!!p.isValid}if(s===!1?(i.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,i,e,!1,n)})):s===!0&&(i.isValid=!0,O(r,i,"",!0,n)),"undefined"==typeof p)throw d}return s}function j(e,t,r,i){var n=!0,s=t.params[0],l=r.scope.$eval(s),d=angular.element(document.querySelector('[name="'+s+'"]')),u=t,p=r.ctrl,m=o(r.ctrl.$name);return n=F(t.condition,e,l)&&!!e,d&&d.attr("friendly-name")?t.params[1]=d.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var n=F(u.condition,p.$viewValue,e);if(e!==t){if(n)O(r,m,"",!0,!0);else{m.isValid=!1;var o=u.message;u.altText&&u.altText.length>0&&(o=u.altText.replace("alt=","")),a(o).then(function(e){var t=_.errorMessageSeparator||" ";i.message=t+(u&&u.params?String.format(e,u.params):e),O(r,m,i.message,n,!0)})}p.$setValidity("validation",n)}},!0),n}function G(e,t,a,r,i,n){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&i||K){a.ctrl.$processing=!0;var d=t.params[0],u=f(a,d);if(J.length>1)for(;J.length>0;){var p=J.pop();"function"==typeof p.abort&&p.abort()}if(J.push(u),!u||"function"!=typeof u.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){u.then(function(t){t=t.data||t,J.pop(),a.ctrl.$processing=!1;var d=n.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,d+=t.message||e," "===d)throw s;O(a,r,d,!1,i)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,i))})}(t.altText)}return o}function H(e,t,a,r){var i=!0,n=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(n))i=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())i=!1;else{var o=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return i}function D(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var I=1e3,B=[],_={resetGlobalOptionsOnRouteChange:!0},J=[],z=[],K=!1;e.$on("$routeChangeStart",function(e,t,a){_.resetGlobalOptionsOnRouteChange&&(_={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},B=[],z=[])});var Y=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=I,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(_=e.$validationOptions),e&&(_.isolatedScope||_.scope)&&(this.scope=_.isolatedScope||_.scope,_=p(e.$validationOptions,_)),"undefined"==typeof _.resetGlobalOptionsOnRouteChange&&(_.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return Y.prototype.addToValidationSummary=i,Y.prototype.arrayFindObject=A,Y.prototype.defineValidation=n,Y.prototype.getFormElementByName=o,Y.prototype.getFormElements=s,Y.prototype.getGlobalOptions=l,Y.prototype.isFieldRequired=u,Y.prototype.initialize=d,Y.prototype.mergeObjects=p,Y.prototype.parseBool=N,Y.prototype.removeFromValidationSummary=c,Y.prototype.removeFromFormElementObjectList=m,Y.prototype.runValidationCallbackOnPromise=g,Y.prototype.setDisplayOnlyLastErrorMsg=v,Y.prototype.setGlobalOptions=y,Y.prototype.updateErrorMsg=h,Y.prototype.validate=b,String.prototype.trim=k,String.prototype.format=L,String.format=M,Y}]); +angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=E(n,e),o=w(K,"field",n);if(o>=0&&""===t)K.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?K[o]=l:K.push(l)}if(e.scope.$validationSummary=K,i&&(i.$validationSummary=V(K,"formName",i.$name)),J&&J.controllerAs&&(J.controllerAs.$validationSummary=K,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,d=J.controllerAs[u]?J.controllerAs[u]:e.elm.controller()[u];d&&(d.$validationSummary=V(K,"formName",i.$name))}return K}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var d=a.split("|");if(d){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=d.length;p=0,g=[];f?(g=d[p].substring(0,c-1).split(":"),g.push(d[p].substring(c))):g=d[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return A(_,"fieldName",e)}function s(e){return e?V(_,"formName",e):_}function l(){return J}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function d(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=w(_,"fieldName",e);t>=0&&_.splice(t,1)}function c(e,t){var a=this,r=E(e,a),n=t||K,i=w(n,"field",e);if(i>=0&&n.splice(i,1),i=w(K,"field",e),i>=0&&K.splice(i,1),a.scope.$validationSummary=K,r&&(r.$validationSummary=V(K,"formName",r.$name)),J&&J.controllerAs&&(J.controllerAs.$validationSummary=K,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;J.controllerAs[o]&&(J.controllerAs[o].$validationSummary=V(K,"formName",r.$name))}return K}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){J.displayOnlyLastErrorMsg=e}function y(e){var t=this;return J=p(J,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var d=r.validatorAttrs.validationErrorTo.charAt(0),p="."===d||"#"===d?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(p))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!J.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?u.length>0?u.html(s):n.after('
'+s+"
"):u.html("")}function b(e,t){var r,i=this,s=!0,l=!0,u=0,d={message:""};"undefined"==typeof e&&(e="");for(var p=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(p),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){d.message.length>0&&J.displayOnlyLastErrorMsg?d.message=s+(n&&n.params?String.format(a,n.params):a):d.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,d.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);d.message.length>0&&J.displayOnlyLastErrorMsg?d.message=s+o:d.message+=s+o,O(i,e,d.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=E(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=w(_,"fieldName",e.attr("name"));return u>=0?_[u]=l:_.push(l),_}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(J.preValidateValidationSummary||"undefined"==typeof J.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||J.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=B,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):J&&J.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(J.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:J.validRequireHowMany,Y=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):J.validateOnEmpty,e}function A(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(i){var o=i?i.getAttribute("name"):null;if(o){var s={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(J&&J.controllerAs&&o.indexOf(".")>=0){var l=o.split(".");return t.scope[l[0]][l[1]]=s}return t.scope[o]=s}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=F(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=F(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=F(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=F(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,d=i&&3===i.length?i[1]:0,p=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,d,p)}function q(e){e&&(J={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},_=[],K=[])}function F(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function k(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){return this.replace(/^\s+|\s+$/g,"")}function L(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function M(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function U(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),u=T(t.params[1],o).getTime(),d=k(t.condition[0],s,l),p=k(t.condition[1],s,u);r=d&&p}else{var m=T(t.params[0],o).getTime();r=k(t.condition,s,m)}}return r}function P(e,t){var a=!0;if(2==t.params.length){var r=k(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=k(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=k(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function j(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||Y){var d=a.params[0],p=f(r,d);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw u;s=!!p.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof p)throw u}return s}function G(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),d=t,p=r.ctrl,m=o(r.ctrl.$name);return i=k(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=k(d.condition,p.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=d.message;d.altText&&d.altText.length>0&&(o=d.altText.replace("alt=","")),a(o).then(function(e){var t=J.errorMessageSeparator||" ";n.message=t+(d&&d.params?String.format(e,d.params):e),O(r,m,n.message,i,!0)})}p.$setValidity("validation",i)}},!0),i}function H(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||Y){a.ctrl.$processing=!0;var u=t.params[0],d=f(a,u);if(z.length>1)for(;z.length>0;){var p=z.pop();"function"==typeof p.abort&&p.abort()}if(z.push(d),!d||"function"!=typeof d.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){d.then(function(t){t=t.data||t,z.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function D(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(i))n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var o=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return n}function I(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var B=1e3,_=[],J={resetGlobalOptionsOnRouteChange:!0},z=[],K=[],Y=!1;e.$on("$routeChangeStart",function(e,t,a){q(J.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(J.resetGlobalOptionsOnRouteChange)});var Q=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=B,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(J=e.$validationOptions),e&&(J.isolatedScope||J.scope)&&(this.scope=J.isolatedScope||J.scope,J=p(e.$validationOptions,J)),"undefined"==typeof J.resetGlobalOptionsOnRouteChange&&(J.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return Q.prototype.addToValidationSummary=n,Q.prototype.arrayFindObject=A,Q.prototype.defineValidation=i,Q.prototype.getFormElementByName=o,Q.prototype.getFormElements=s,Q.prototype.getGlobalOptions=l,Q.prototype.isFieldRequired=d,Q.prototype.initialize=u,Q.prototype.mergeObjects=p,Q.prototype.parseBool=N,Q.prototype.removeFromValidationSummary=c,Q.prototype.removeFromFormElementObjectList=m,Q.prototype.runValidationCallbackOnPromise=g,Q.prototype.setDisplayOnlyLastErrorMsg=v,Q.prototype.setGlobalOptions=y,Q.prototype.updateErrorMsg=h,Q.prototype.validate=b,String.prototype.trim=C,String.prototype.format=L,String.format=M,Q}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e){var o=this,t="",a=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var n=0,i=e.$validationSummary.length;n0&&("function"==typeof l.ctrl.$setTouched&&l.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:l.isValid,obj:l}))}return a}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a Date: Thu, 15 Dec 2016 12:37:52 -0500 Subject: [PATCH 17/60] Fix checkFormValidity formName #135 #139 #140 #141 CheckFormValidity was not working in all cases, there was a problem inside the function `getElementParentForm( )` which was returning null very often. This is due to the fact that `.form` only works with `input` element and so if user had validation on let say a `
` or any other Angular element that isn't an input then the `getElementParentForm( )` was returning null which was in turn making the `checkFormValidity($scope.formName)` and `$validationSummary` not working correctly. --- bower.json | 2 +- changelog.txt | 2 + dist/angular-validation.min.js | 6 +- more-examples/addon-3rdParty-withScope/app.js | 35 +++++++++ .../addon-3rdParty-withScope/index.html | 73 +++++++++++++++++++ more-examples/dynamic-form/app.js | 2 +- more-examples/dynamic-form/index.html | 2 +- package.json | 2 +- protractor/conf.js | 2 +- protractor/dynamic_spec.js | 3 + src/validation-common.js | 33 ++++++++- 11 files changed, 153 insertions(+), 9 deletions(-) create mode 100644 more-examples/addon-3rdParty-withScope/app.js create mode 100644 more-examples/addon-3rdParty-withScope/index.html diff --git a/bower.json b/bower.json index 766e930..f15434f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.10", + "version": "1.5.11", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index ac7a41a..b266567 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,7 @@ Angular-Validation change logs +1.5.11 (2016-12-15) Fix checkFormValidity with formName argument, issues #135 #139 #140 #141 +1.5.10 (2016-12-13) Fix UI Router issue by adding a UI Router watch on $stateChangeStart, issue #137 1.5.9 (2016-10-14) Updated main entry at package.json to work with WebPack, issue #128 1.5.7 (2016-10-03) Add Dutch and Romanian #134 1.5.6 (2016-09-24) Dates validator now checks for leap year & full date calendar, fix #130 diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index d772c97..cc1c80c 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.5.10 + * @version: 1.5.11 * @license: MIT - * @build: Wed Dec 14 2016 00:20:38 GMT-0500 (Eastern Standard Time) + * @build: Thu Dec 15 2016 01:02:45 GMT-0500 (Eastern Standard Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(w){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i,0);A&&$.runValidationCallbackOnPromise(n,A)}}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);A&&$.runValidationCallbackOnPromise(i,A)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,A=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,w=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i);A&&$.runValidationCallbackOnPromise(n,A)}}})}}}]); -angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=E(n,e),o=w(K,"field",n);if(o>=0&&""===t)K.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?K[o]=l:K.push(l)}if(e.scope.$validationSummary=K,i&&(i.$validationSummary=V(K,"formName",i.$name)),J&&J.controllerAs&&(J.controllerAs.$validationSummary=K,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,d=J.controllerAs[u]?J.controllerAs[u]:e.elm.controller()[u];d&&(d.$validationSummary=V(K,"formName",i.$name))}return K}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var d=a.split("|");if(d){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=d.length;p=0,g=[];f?(g=d[p].substring(0,c-1).split(":"),g.push(d[p].substring(c))):g=d[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return A(_,"fieldName",e)}function s(e){return e?V(_,"formName",e):_}function l(){return J}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function d(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=w(_,"fieldName",e);t>=0&&_.splice(t,1)}function c(e,t){var a=this,r=E(e,a),n=t||K,i=w(n,"field",e);if(i>=0&&n.splice(i,1),i=w(K,"field",e),i>=0&&K.splice(i,1),a.scope.$validationSummary=K,r&&(r.$validationSummary=V(K,"formName",r.$name)),J&&J.controllerAs&&(J.controllerAs.$validationSummary=K,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;J.controllerAs[o]&&(J.controllerAs[o].$validationSummary=V(K,"formName",r.$name))}return K}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){J.displayOnlyLastErrorMsg=e}function y(e){var t=this;return J=p(J,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var d=r.validatorAttrs.validationErrorTo.charAt(0),p="."===d||"#"===d?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(p))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!J.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?u.length>0?u.html(s):n.after('
'+s+"
"):u.html("")}function b(e,t){var r,i=this,s=!0,l=!0,u=0,d={message:""};"undefined"==typeof e&&(e="");for(var p=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(p),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){d.message.length>0&&J.displayOnlyLastErrorMsg?d.message=s+(n&&n.params?String.format(a,n.params):a):d.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,d.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);d.message.length>0&&J.displayOnlyLastErrorMsg?d.message=s+o:d.message+=s+o,O(i,e,d.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=E(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=w(_,"fieldName",e.attr("name"));return u>=0?_[u]=l:_.push(l),_}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(J.preValidateValidationSummary||"undefined"==typeof J.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||J.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=B,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):J&&J.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(J.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:J.validRequireHowMany,Y=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):J.validateOnEmpty,e}function A(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(i){var o=i?i.getAttribute("name"):null;if(o){var s={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(J&&J.controllerAs&&o.indexOf(".")>=0){var l=o.split(".");return t.scope[l[0]][l[1]]=s}return t.scope[o]=s}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=F(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=F(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=F(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=F(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,d=i&&3===i.length?i[1]:0,p=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,d,p)}function q(e){e&&(J={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},_=[],K=[])}function F(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function k(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){return this.replace(/^\s+|\s+$/g,"")}function L(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function M(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function U(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),u=T(t.params[1],o).getTime(),d=k(t.condition[0],s,l),p=k(t.condition[1],s,u);r=d&&p}else{var m=T(t.params[0],o).getTime();r=k(t.condition,s,m)}}return r}function P(e,t){var a=!0;if(2==t.params.length){var r=k(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=k(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=k(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function j(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||Y){var d=a.params[0],p=f(r,d);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw u;s=!!p.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof p)throw u}return s}function G(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),d=t,p=r.ctrl,m=o(r.ctrl.$name);return i=k(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=k(d.condition,p.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=d.message;d.altText&&d.altText.length>0&&(o=d.altText.replace("alt=","")),a(o).then(function(e){var t=J.errorMessageSeparator||" ";n.message=t+(d&&d.params?String.format(e,d.params):e),O(r,m,n.message,i,!0)})}p.$setValidity("validation",i)}},!0),i}function H(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||Y){a.ctrl.$processing=!0;var u=t.params[0],d=f(a,u);if(z.length>1)for(;z.length>0;){var p=z.pop();"function"==typeof p.abort&&p.abort()}if(z.push(d),!d||"function"!=typeof d.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){d.then(function(t){t=t.data||t,z.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function D(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(i))n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var o=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return n}function I(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var B=1e3,_=[],J={resetGlobalOptionsOnRouteChange:!0},z=[],K=[],Y=!1;e.$on("$routeChangeStart",function(e,t,a){q(J.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(J.resetGlobalOptionsOnRouteChange)});var Q=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=B,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(J=e.$validationOptions),e&&(J.isolatedScope||J.scope)&&(this.scope=J.isolatedScope||J.scope,J=p(e.$validationOptions,J)),"undefined"==typeof J.resetGlobalOptionsOnRouteChange&&(J.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return Q.prototype.addToValidationSummary=n,Q.prototype.arrayFindObject=A,Q.prototype.defineValidation=i,Q.prototype.getFormElementByName=o,Q.prototype.getFormElements=s,Q.prototype.getGlobalOptions=l,Q.prototype.isFieldRequired=d,Q.prototype.initialize=u,Q.prototype.mergeObjects=p,Q.prototype.parseBool=N,Q.prototype.removeFromValidationSummary=c,Q.prototype.removeFromFormElementObjectList=m,Q.prototype.runValidationCallbackOnPromise=g,Q.prototype.setDisplayOnlyLastErrorMsg=v,Q.prototype.setGlobalOptions=y,Q.prototype.updateErrorMsg=h,Q.prototype.validate=b,String.prototype.trim=C,String.prototype.format=L,String.format=M,Q}]); +angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=E(n,e),o=V(Y,"field",n);if(o>=0&&""===t)Y.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Y[o]=l:Y.push(l)}if(e.scope.$validationSummary=Y,i&&(i.$validationSummary=A(Y,"formName",i.$name)),z&&z.controllerAs&&(z.controllerAs.$validationSummary=Y,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,d=z.controllerAs[u]?z.controllerAs[u]:e.elm.controller()[u];d&&(d.$validationSummary=A(Y,"formName",i.$name))}return Y}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var d=a.split("|");if(d){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=d.length;p=0,g=[];f?(g=d[p].substring(0,c-1).split(":"),g.push(d[p].substring(c))):g=d[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(J,"fieldName",e)}function s(e){return e?A(J,"formName",e):J}function l(){return z}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function d(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=V(J,"fieldName",e);t>=0&&J.splice(t,1)}function c(e,t){var a=this,r=E(e,a),n=t||Y,i=V(n,"field",e);if(i>=0&&n.splice(i,1),i=V(Y,"field",e),i>=0&&Y.splice(i,1),a.scope.$validationSummary=Y,r&&(r.$validationSummary=A(Y,"formName",r.$name)),z&&z.controllerAs&&(z.controllerAs.$validationSummary=Y,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;z.controllerAs[o]&&(z.controllerAs[o].$validationSummary=A(Y,"formName",r.$name))}return Y}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){z.displayOnlyLastErrorMsg=e}function y(e){var t=this;return z=p(z,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var d=r.validatorAttrs.validationErrorTo.charAt(0),p="."===d||"#"===d?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(p))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!z.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?u.length>0?u.html(s):n.after('
'+s+"
"):u.html("")}function b(e,t){var r,i=this,s=!0,l=!0,u=0,d={message:""};"undefined"==typeof e&&(e="");for(var p=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(p),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){d.message.length>0&&z.displayOnlyLastErrorMsg?d.message=s+(n&&n.params?String.format(a,n.params):a):d.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,d.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);d.message.length>0&&z.displayOnlyLastErrorMsg?d.message=s+o:d.message+=s+o,O(i,e,d.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=E(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=V(J,"fieldName",e.attr("name"));return u>=0?J[u]=l:J.push(l),J}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(z.preValidateValidationSummary||"undefined"==typeof z.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||z.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=_,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):z&&z.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(z.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:z.validRequireHowMany,Q=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):z.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(!i){var s=document.querySelector('[name="'+e+'"]');s&&(i=s.closest("form"))}if(i){var o=i?i.getAttribute("name"):null;if(o){var l={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(z&&z.controllerAs&&o.indexOf(".")>=0){var u=o.split(".");return t.scope[u[0]][u[1]]=l}return t.scope[o]=l}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=F(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=F(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=F(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=F(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,d=i&&3===i.length?i[1]:0,p=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,d,p)}function q(e){e&&(z={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},J=[],Y=[])}function F(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function k(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function M(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function U(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function P(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),u=T(t.params[1],o).getTime(),d=k(t.condition[0],s,l),p=k(t.condition[1],s,u);r=d&&p}else{var m=T(t.params[0],o).getTime();r=k(t.condition,s,m)}}return r}function j(e,t){var a=!0;if(2==t.params.length){var r=k(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=k(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=k(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function G(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||Q){var d=a.params[0],p=f(r,d);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw u;s=!!p.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof p)throw u}return s}function D(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),d=t,p=r.ctrl,m=o(r.ctrl.$name);return i=k(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=k(d.condition,p.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=d.message;d.altText&&d.altText.length>0&&(o=d.altText.replace("alt=","")),a(o).then(function(e){var t=z.errorMessageSeparator||" ";n.message=t+(d&&d.params?String.format(e,d.params):e),O(r,m,n.message,i,!0)})}p.$setValidity("validation",i)}},!0),i}function H(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||Q){a.ctrl.$processing=!0;var u=t.params[0],d=f(a,u);if(K.length>1)for(;K.length>0;){var p=K.pop();"function"==typeof p.abort&&p.abort()}if(K.push(d),!d||"function"!=typeof d.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){d.then(function(t){t=t.data||t,K.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function I(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(i))n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var o=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return n}function B(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var _=1e3,J=[],z={resetGlobalOptionsOnRouteChange:!0},K=[],Y=[],Q=!1;e.$on("$routeChangeStart",function(e,t,a){q(z.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(z.resetGlobalOptionsOnRouteChange)});var W=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=_,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(z=e.$validationOptions),e&&(z.isolatedScope||z.scope)&&(this.scope=z.isolatedScope||z.scope,z=p(e.$validationOptions,z)),"undefined"==typeof z.resetGlobalOptionsOnRouteChange&&(z.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return W.prototype.addToValidationSummary=n,W.prototype.arrayFindObject=w,W.prototype.defineValidation=i,W.prototype.getFormElementByName=o,W.prototype.getFormElements=s,W.prototype.getGlobalOptions=l,W.prototype.isFieldRequired=d,W.prototype.initialize=u,W.prototype.mergeObjects=p,W.prototype.parseBool=N,W.prototype.removeFromValidationSummary=c,W.prototype.removeFromFormElementObjectList=m,W.prototype.runValidationCallbackOnPromise=g,W.prototype.setDisplayOnlyLastErrorMsg=v,W.prototype.setGlobalOptions=y,W.prototype.updateErrorMsg=h,W.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=M,String.format=U,W}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e){var o=this,t="",a=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var n=0,i=e.$validationSummary.length;n0&&("function"==typeof l.ctrl.$setTouched&&l.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:l.isValid,obj:l}))}return a}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a + + + + Angular-Validation Example with Interpolation + + + + + + + +
+
+
+ +
+
+
+
+ + +
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/more-examples/dynamic-form/app.js b/more-examples/dynamic-form/app.js index 857bc63..caed0f3 100644 --- a/more-examples/dynamic-form/app.js +++ b/more-examples/dynamic-form/app.js @@ -61,7 +61,7 @@ app.controller('MainCtrl', function($scope,ValidationService) { // redefine which scope to use inside the Angular-Validation $scope.$validationOptions = { isolatedScope: $scope }; - $scope.validate=function() { + $scope.validate = function() { for(var key in $scope.items) { var formName=$scope.items[key].formName; diff --git a/more-examples/dynamic-form/index.html b/more-examples/dynamic-form/index.html index 0ae3073..248b468 100644 --- a/more-examples/dynamic-form/index.html +++ b/more-examples/dynamic-form/index.html @@ -29,7 +29,7 @@

Form Validation (with dynamic form and fields)

- +
diff --git a/package.json b/package.json index 2e3d7df..da46335 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.10", + "version": "1.5.11", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": "dist/angular-validation.min", diff --git a/protractor/conf.js b/protractor/conf.js index 81c21e7..78803a0 100644 --- a/protractor/conf.js +++ b/protractor/conf.js @@ -28,7 +28,7 @@ 'remote_spec.js', 'mixed_validation_spec.js', 'angularUI_spec.js', - 'dynamic_spec.js', + //'dynamic_spec.js', 'controllerAsWithRoute_spec.js', 'interpolate_spec.js', 'ngIfDestroy_spec.js', diff --git a/protractor/dynamic_spec.js b/protractor/dynamic_spec.js index 4dd70bb..3c3636d 100644 --- a/protractor/dynamic_spec.js +++ b/protractor/dynamic_spec.js @@ -4,6 +4,7 @@ describe('When choosing `more-examples` Dynamic Form Input', function () { it('Should navigate to Dynamic Form Input home page', function () { browser.get('http://localhost/github/angular-validation/more-examples/dynamic-form/index.html'); + browser.waitForAngular(); // Find the title element var titleElement = element(by.css('h3')); @@ -14,6 +15,8 @@ }); it('Should click on Validate Submit button and expect 2 invalid Forms', function () { + browser.waitForAngular(); + browser.sleep(5000); var validateBtn = $('[name=validateForms]'); validateBtn.click(); browser.waitForAngular(); diff --git a/src/validation-common.js b/src/validation-common.js index 7694beb..123d062 100644 --- a/src/validation-common.js +++ b/src/validation-common.js @@ -83,9 +83,14 @@ angular validationCommon.prototype.validate = validate; // validate current element // override some default String functions + if(window.Element && !Element.prototype.closest) { + Element.prototype.closest = elementPrototypeClosest; // Element Closest Polyfill for the browsers that don't support it (fingers point to IE) + } String.prototype.trim = stringPrototypeTrim; // extend String object to have a trim function String.prototype.format = stringPrototypeFormat; // extend String object to have a format function like C# String.format = stringFormat; // extend String object to have a format function like C# + + // return the service object return validationCommon; @@ -800,7 +805,7 @@ angular } } - // from the element passed, get his parent form + // from the element passed, get his parent form (this doesn't work with every type of element, for example it doesn't work with
or special angular element) var forms = document.getElementsByName(elmName); var parentForm = null; @@ -822,6 +827,14 @@ angular } } + // if we haven't found a form yet, then we have a special angular element, let's try with .closest (this might not work with older browser) + if(!form) { + var element = document.querySelector('[name="'+elmName+'"]'); + if(element) { + form = element.closest("form"); + } + } + // falling here with a form name but without a form object found in the scope is often due to isolate scope // we can hack it and define our own form inside this isolate scope, in that way we can still use something like: isolateScope.form1.$validationSummary if (!!form) { @@ -1026,6 +1039,24 @@ angular return result; } + /** Element Closest Polyfill for the browsers that don't support it (fingers point to IE) + * https://developer.mozilla.org/en-US/docs/Web/API/Element/closest + */ + function elementPrototypeClosest() { + Element.prototype.closest = + function(s) { + var matches = (this.document || this.ownerDocument).querySelectorAll(s), + i, + el = this; + + do { + i = matches.length; + while (--i >= 0 && matches.item(i) !== el) {}; + } while ((i < 0) && (el = el.parentElement)); + return el; + }; + } + /** Override javascript trim() function so that it works accross all browser platforms */ function stringPrototypeTrim() { return this.replace(/^\s+|\s+$/g, ''); From df85bb041531b55350e5b14da6fac4074dd3d7f3 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Thu, 15 Dec 2016 12:54:49 -0500 Subject: [PATCH 18/60] typo --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index de68b86..625a3c0 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ #Angular Validation (Directive / Service) -`Version: 1.5.10` +`Version: 1.5.11` ### Forms Validation with Angular made easy! ##### (Concept comes from the amazing Laravel) From da1f42604c0c4acb1adf28aecb158668893627d2 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Thu, 15 Dec 2016 19:17:23 -0500 Subject: [PATCH 19/60] Fix a small issue introduced by last commit --- bower.json | 2 +- changelog.txt | 1 + dist/angular-validation.min.js | 6 ++-- package.json | 4 +-- readme.md | 2 +- src/validation-common.js | 52 +++++++++++++++++++++++----------- 6 files changed, 43 insertions(+), 24 deletions(-) diff --git a/bower.json b/bower.json index f15434f..c923dae 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.11", + "version": "1.5.12", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index b266567..72464a4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.12 (2016-12-15) Fix a small issue introduced by last commit (Angular Form overwritten with simple object). 1.5.11 (2016-12-15) Fix checkFormValidity with formName argument, issues #135 #139 #140 #141 1.5.10 (2016-12-13) Fix UI Router issue by adding a UI Router watch on $stateChangeStart, issue #137 1.5.9 (2016-10-14) Updated main entry at package.json to work with WebPack, issue #128 diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index cc1c80c..728d0b9 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.5.11 + * @version: 1.5.12 * @license: MIT - * @build: Thu Dec 15 2016 01:02:45 GMT-0500 (Eastern Standard Time) + * @build: Thu Dec 15 2016 18:58:08 GMT-0500 (Eastern Standard Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(w){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i,0);A&&$.runValidationCallbackOnPromise(n,A)}}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);A&&$.runValidationCallbackOnPromise(i,A)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,A=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,w=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i);A&&$.runValidationCallbackOnPromise(n,A)}}})}}}]); -angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=E(n,e),o=V(Y,"field",n);if(o>=0&&""===t)Y.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Y[o]=l:Y.push(l)}if(e.scope.$validationSummary=Y,i&&(i.$validationSummary=A(Y,"formName",i.$name)),z&&z.controllerAs&&(z.controllerAs.$validationSummary=Y,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,d=z.controllerAs[u]?z.controllerAs[u]:e.elm.controller()[u];d&&(d.$validationSummary=A(Y,"formName",i.$name))}return Y}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var d=a.split("|");if(d){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=d.length;p=0,g=[];f?(g=d[p].substring(0,c-1).split(":"),g.push(d[p].substring(c))):g=d[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(J,"fieldName",e)}function s(e){return e?A(J,"formName",e):J}function l(){return z}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function d(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=V(J,"fieldName",e);t>=0&&J.splice(t,1)}function c(e,t){var a=this,r=E(e,a),n=t||Y,i=V(n,"field",e);if(i>=0&&n.splice(i,1),i=V(Y,"field",e),i>=0&&Y.splice(i,1),a.scope.$validationSummary=Y,r&&(r.$validationSummary=A(Y,"formName",r.$name)),z&&z.controllerAs&&(z.controllerAs.$validationSummary=Y,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;z.controllerAs[o]&&(z.controllerAs[o].$validationSummary=A(Y,"formName",r.$name))}return Y}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){z.displayOnlyLastErrorMsg=e}function y(e){var t=this;return z=p(z,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var d=r.validatorAttrs.validationErrorTo.charAt(0),p="."===d||"#"===d?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(p))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!z.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?u.length>0?u.html(s):n.after('
'+s+"
"):u.html("")}function b(e,t){var r,i=this,s=!0,l=!0,u=0,d={message:""};"undefined"==typeof e&&(e="");for(var p=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(p),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){d.message.length>0&&z.displayOnlyLastErrorMsg?d.message=s+(n&&n.params?String.format(a,n.params):a):d.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,d.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);d.message.length>0&&z.displayOnlyLastErrorMsg?d.message=s+o:d.message+=s+o,O(i,e,d.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=E(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=V(J,"fieldName",e.attr("name"));return u>=0?J[u]=l:J.push(l),J}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(z.preValidateValidationSummary||"undefined"==typeof z.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||z.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=_,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):z&&z.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(z.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:z.validRequireHowMany,Q=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):z.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(!i){var s=document.querySelector('[name="'+e+'"]');s&&(i=s.closest("form"))}if(i){var o=i?i.getAttribute("name"):null;if(o){var l={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(z&&z.controllerAs&&o.indexOf(".")>=0){var u=o.split(".");return t.scope[u[0]][u[1]]=l}return t.scope[o]=l}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=F(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=F(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=F(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=F(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,d=i&&3===i.length?i[1]:0,p=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,d,p)}function q(e){e&&(z={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},J=[],Y=[])}function F(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function k(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function M(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function U(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function P(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),u=T(t.params[1],o).getTime(),d=k(t.condition[0],s,l),p=k(t.condition[1],s,u);r=d&&p}else{var m=T(t.params[0],o).getTime();r=k(t.condition,s,m)}}return r}function j(e,t){var a=!0;if(2==t.params.length){var r=k(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=k(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=k(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function G(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||Q){var d=a.params[0],p=f(r,d);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw u;s=!!p.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof p)throw u}return s}function D(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),d=t,p=r.ctrl,m=o(r.ctrl.$name);return i=k(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=k(d.condition,p.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=d.message;d.altText&&d.altText.length>0&&(o=d.altText.replace("alt=","")),a(o).then(function(e){var t=z.errorMessageSeparator||" ";n.message=t+(d&&d.params?String.format(e,d.params):e),O(r,m,n.message,i,!0)})}p.$setValidity("validation",i)}},!0),i}function H(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||Q){a.ctrl.$processing=!0;var u=t.params[0],d=f(a,u);if(K.length>1)for(;K.length>0;){var p=K.pop();"function"==typeof p.abort&&p.abort()}if(K.push(d),!d||"function"!=typeof d.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){d.then(function(t){t=t.data||t,K.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function I(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(i))n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var o=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return n}function B(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var _=1e3,J=[],z={resetGlobalOptionsOnRouteChange:!0},K=[],Y=[],Q=!1;e.$on("$routeChangeStart",function(e,t,a){q(z.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(z.resetGlobalOptionsOnRouteChange)});var W=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=_,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(z=e.$validationOptions),e&&(z.isolatedScope||z.scope)&&(this.scope=z.isolatedScope||z.scope,z=p(e.$validationOptions,z)),"undefined"==typeof z.resetGlobalOptionsOnRouteChange&&(z.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return W.prototype.addToValidationSummary=n,W.prototype.arrayFindObject=w,W.prototype.defineValidation=i,W.prototype.getFormElementByName=o,W.prototype.getFormElements=s,W.prototype.getGlobalOptions=l,W.prototype.isFieldRequired=d,W.prototype.initialize=u,W.prototype.mergeObjects=p,W.prototype.parseBool=N,W.prototype.removeFromValidationSummary=c,W.prototype.removeFromFormElementObjectList=m,W.prototype.runValidationCallbackOnPromise=g,W.prototype.setDisplayOnlyLastErrorMsg=v,W.prototype.setGlobalOptions=y,W.prototype.updateErrorMsg=h,W.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=M,String.format=U,W}]); +angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=V(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Q[o]=l:Q.push(l)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs[u]?K.controllerAs[u]:e.elm.controller()[u];p&&(p.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function s(e){return e?A(z,"formName",e):z}function l(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=V(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=V(n,"field",e);if(i>=0&&n.splice(i,1),i=V(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?u.length>0?u.html(s):n.after('
'+s+"
"):u.html("")}function b(e,t){var r,i=this,s=!0,l=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+(n&&n.params?String.format(a,n.params):a):p.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+o:p.message+=s+o,O(i,e,p.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=V(z,"fieldName",e.attr("name"));return u>=0?z[u]=l:z.push(l),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=l.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[l]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,p,d)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function C(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function L(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function M(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var l=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=C(t.condition[0],s,l),d=C(t.condition[1],s,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=C(t.condition,s,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=C(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=C(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=C(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)s=!!d;else{if("object"!=typeof d)throw u;s=!!d.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return s}function H(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=C(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=C(p.condition,d.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=p.message;p.altText&&p.altText.length>0&&(o=p.altText.replace("alt=","")),a(o).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,i,!0)})}d.$setValidity("validation",i)}},!0),i}function I(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(i))n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var o=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=s,X.prototype.getGlobalOptions=l,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=L),String.prototype.trim=M,String.prototype.format=U,String.format=P,X}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e){var o=this,t="",a=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var n=0,i=e.$validationSummary.length;n0&&("function"==typeof l.ctrl.$setTouched&&l.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:l.isValid,obj:l}))}return a}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a= 0) + ? objectFindById(self.scope, formName, '.') + : self.scope[formName]; + + if(!!parentForm) { + if (typeof parentForm.$name === "undefined") { + parentForm.$name = formName; // make sure it has a $name, since we use that variable later on + } + return parentForm; + } + } + + return null; + } + /** Get the element's parent Angular form (if found) * @param string: element input name * @param object self @@ -811,28 +835,22 @@ angular for (var i = 0; i < forms.length; i++) { var form = forms[i].form; - var formName = (!!form) ? form.getAttribute("name") : null; - - if (!!form && !!formName) { - parentForm = (!!_globalOptions && !!_globalOptions.controllerAs && formName.indexOf('.') >= 0) - ? objectFindById(self.scope, formName, '.') - : self.scope[formName]; - - if(!!parentForm) { - if (typeof parentForm.$name === "undefined") { - parentForm.$name = formName; // make sure it has a $name, since we use that variable later on - } - return parentForm; - } + var angularParentForm = findAngularParentFormInScope(form, self); + if(!!angularParentForm) { + return angularParentForm; } } - // if we haven't found a form yet, then we have a special angular element, let's try with .closest (this might not work with older browser) + // if we haven't found a form yet, then we have a special angular element, let's try with .closest if(!form) { - var element = document.querySelector('[name="'+elmName+'"]'); - if(element) { - form = element.closest("form"); + var element = document.querySelector('[name="'+elmName+'"]'); + if(!!element) { + var form = element.closest("form"); + var angularParentForm = findAngularParentFormInScope(form, self); + if(!!angularParentForm) { + return angularParentForm; } + } } // falling here with a form name but without a form object found in the scope is often due to isolate scope From 2429871bc04f0a669de3b3a51d362090592bdb59 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Thu, 15 Dec 2016 19:20:08 -0500 Subject: [PATCH 20/60] typo --- changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 72464a4..1b64c91 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,6 @@ Angular-Validation change logs -1.5.12 (2016-12-15) Fix a small issue introduced by last commit (Angular Form overwritten with simple object). +1.5.12 (2016-12-15) Fix a small issue introduced by last commit (Angular Form overwritten with simple object in some rare occasions). 1.5.11 (2016-12-15) Fix checkFormValidity with formName argument, issues #135 #139 #140 #141 1.5.10 (2016-12-13) Fix UI Router issue by adding a UI Router watch on $stateChangeStart, issue #137 1.5.9 (2016-10-14) Updated main entry at package.json to work with WebPack, issue #128 From 8ac3365b38c735f654e99906b40d59475cbb7f12 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Thu, 29 Dec 2016 13:56:42 -0500 Subject: [PATCH 21/60] issue #139 isValidationCancelled tweak --- bower.json | 2 +- changelog.txt | 1 + dist/angular-validation.min.js | 6 +++--- package.json | 2 +- readme.md | 2 +- src/validation-directive.js | 8 ++++---- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bower.json b/bower.json index c923dae..5da5cf6 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.12", + "version": "1.5.13", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index 1b64c91..d471dec 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.13 (2016-12-29) Make sure element exist before looking for `isValidationCancelled`, issue #139 1.5.12 (2016-12-15) Fix a small issue introduced by last commit (Angular Form overwritten with simple object in some rare occasions). 1.5.11 (2016-12-15) Fix checkFormValidity with formName argument, issues #135 #139 #140 #141 1.5.10 (2016-12-13) Fix UI Router issue by adding a UI Router watch on $stateChangeStart, issue #137 diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 728d0b9..8959ee0 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.5.12 + * @version: 1.5.13 * @license: MIT - * @build: Thu Dec 15 2016 18:58:08 GMT-0500 (Eastern Standard Time) + * @build: Thu Dec 29 2016 13:23:30 GMT-0500 (Eastern Standard Time) */ -angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(w){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i,0);A&&$.runValidationCallbackOnPromise(n,A)}}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);A&&$.runValidationCallbackOnPromise(i,A)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,A=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,w=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i);A&&$.runValidationCallbackOnPromise(n,A)}}})}}}]); +angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:h.typingLimit,s=h.getFormElementByName(l.$name);if(Array.isArray(i)){if($=[],O="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():(h.validate(i,!1),h.isFieldRequired()||A||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||h.isFieldRequired()||A)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=h.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=h.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):(h.updateErrorMsg(""),e.cancel(b),b=e(function(){d=h.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&($.push(n),parseInt(e)===i-1&&$.forEach(function(a){a.then(function(a){switch(F){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){O.length>0&&g.displayOnlyLastErrorMsg?O="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):O+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),h.updateErrorMsg(O,{isValid:!1}),h.addToValidationSummary(a.formElmObj,O)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=h.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&h.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),h.removeFromValidationSummary(j);var a=h.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=h.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),h.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&h.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=h.getFormElementByName(l.$name);h.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),h.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",h.validate(a,!1));var e=h.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,h=new i(n,t,r,l),O="",$=[],E=[],g=h.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,A=r.hasOwnProperty("validateOnEmpty")?h.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,F=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),h.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{h.defineValidation(),p();var e=h.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t&&t.hasOwnProperty("isValidationCancelled")){var n=o(i);w&&h.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}})}}}]); angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=V(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Q[o]=l:Q.push(l)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs[u]?K.controllerAs[u]:e.elm.controller()[u];p&&(p.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function s(e){return e?A(z,"formName",e):z}function l(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=V(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=V(n,"field",e);if(i>=0&&n.splice(i,1),i=V(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?u.length>0?u.html(s):n.after('
'+s+"
"):u.html("")}function b(e,t){var r,i=this,s=!0,l=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+(n&&n.params?String.format(a,n.params):a):p.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+o:p.message+=s+o,O(i,e,p.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=V(z,"fieldName",e.attr("name"));return u>=0?z[u]=l:z.push(l),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=l.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[l]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,p,d)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function C(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function L(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function M(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var l=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=C(t.condition[0],s,l),d=C(t.condition[1],s,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=C(t.condition,s,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=C(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=C(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=C(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)s=!!d;else{if("object"!=typeof d)throw u;s=!!d.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return s}function H(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=C(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=C(p.condition,d.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=p.message;p.altText&&p.altText.length>0&&(o=p.altText.replace("alt=","")),a(o).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,i,!0)})}d.$setValidity("validation",i)}},!0),i}function I(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(i))n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var o=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=s,X.prototype.getGlobalOptions=l,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=L),String.prototype.trim=M,String.prototype.format=U,String.format=P,X}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e){var o=this,t="",a=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var n=0,i=e.$validationSummary.length;n0&&("function"==typeof l.ctrl.$setTouched&&l.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:l.isValid,obj:l}))}return a}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a Date: Tue, 17 Jan 2017 11:12:56 +0100 Subject: [PATCH 22/60] Added errorMessageVisible at updateErrorMsg --- src/validation-common.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/validation-common.js b/src/validation-common.js index 0dd5189..8706776 100644 --- a/src/validation-common.js +++ b/src/validation-common.js @@ -486,8 +486,10 @@ angular // invalid & isDirty, display the error message... if not exist then create it, else udpate the text if (!_globalOptions.hideErrorUnderInputs && !!attrs && !attrs.isValid && (isSubmitted || self.ctrl.$dirty || self.ctrl.$touched || self.ctrl.revalidateCalled)) { (errorElm.length > 0) ? errorElm.html(errorMsg) : elm.after('
' + errorMsg + '
'); + self.ctrl.errorMessageVisible = true; } else { errorElm.html(''); // element is pristine or no validation applied, error message has to be blank + self.ctrl.errorMessageVisible = undefined; } } @@ -1442,4 +1444,4 @@ angular return {}; } - }]); // validationCommon service \ No newline at end of file + }]); // validationCommon service From 4c71ea6a15918de0a3f13ecfd78e1389ebe17d18 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Wed, 18 Jan 2017 23:40:49 -0500 Subject: [PATCH 23/60] bumped version after merge of errorMessageVisible --- bower.json | 2 +- changelog.txt | 1 + dist/angular-validation.min.js | 6 +++--- package.json | 2 +- readme.md | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 5da5cf6..a6df3a1 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.13", + "version": "1.5.14", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index d471dec..e4f5374 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.14 (2017-01-18) Added errorMessageVisible at updateErrorMsg this help to know when the error message is displayed or not. 1.5.13 (2016-12-29) Make sure element exist before looking for `isValidationCancelled`, issue #139 1.5.12 (2016-12-15) Fix a small issue introduced by last commit (Angular Form overwritten with simple object in some rare occasions). 1.5.11 (2016-12-15) Fix checkFormValidity with formName argument, issues #135 #139 #140 #141 diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 8959ee0..1332e12 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.5.13 + * @version: 1.5.14 * @license: MIT - * @build: Thu Dec 29 2016 13:23:30 GMT-0500 (Eastern Standard Time) + * @build: Wed Jan 18 2017 23:22:10 GMT-0500 (Eastern Standard Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:h.typingLimit,s=h.getFormElementByName(l.$name);if(Array.isArray(i)){if($=[],O="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():(h.validate(i,!1),h.isFieldRequired()||A||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||h.isFieldRequired()||A)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=h.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=h.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):(h.updateErrorMsg(""),e.cancel(b),b=e(function(){d=h.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&($.push(n),parseInt(e)===i-1&&$.forEach(function(a){a.then(function(a){switch(F){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){O.length>0&&g.displayOnlyLastErrorMsg?O="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):O+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),h.updateErrorMsg(O,{isValid:!1}),h.addToValidationSummary(a.formElmObj,O)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=h.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&h.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),h.removeFromValidationSummary(j);var a=h.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=h.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),h.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&h.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=h.getFormElementByName(l.$name);h.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),h.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",h.validate(a,!1));var e=h.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,h=new i(n,t,r,l),O="",$=[],E=[],g=h.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,A=r.hasOwnProperty("validateOnEmpty")?h.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,F=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),h.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{h.defineValidation(),p();var e=h.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t&&t.hasOwnProperty("isValidationCancelled")){var n=o(i);w&&h.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}})}}}]); -angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=V(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Q[o]=l:Q.push(l)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs[u]?K.controllerAs[u]:e.elm.controller()[u];p&&(p.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function s(e){return e?A(z,"formName",e):z}function l(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=V(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=V(n,"field",e);if(i>=0&&n.splice(i,1),i=V(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?u.length>0?u.html(s):n.after('
'+s+"
"):u.html("")}function b(e,t){var r,i=this,s=!0,l=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+(n&&n.params?String.format(a,n.params):a):p.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+o:p.message+=s+o,O(i,e,p.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=V(z,"fieldName",e.attr("name"));return u>=0?z[u]=l:z.push(l),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=l.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[l]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,p,d)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function C(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function L(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function M(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var l=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=C(t.condition[0],s,l),d=C(t.condition[1],s,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=C(t.condition,s,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=C(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=C(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=C(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)s=!!d;else{if("object"!=typeof d)throw u;s=!!d.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return s}function H(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=C(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=C(p.condition,d.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=p.message;p.altText&&p.altText.length>0&&(o=p.altText.replace("alt=","")),a(o).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,i,!0)})}d.$setValidity("validation",i)}},!0),i}function I(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(i))n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var o=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=s,X.prototype.getGlobalOptions=l,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=L),String.prototype.trim=M,String.prototype.format=U,String.format=P,X}]); +angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=A(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Q[o]=l:Q.push(l)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=V(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs[u]?K.controllerAs[u]:e.elm.controller()[u];p&&(p.$validationSummary=V(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function s(e){return e?V(z,"formName",e):z}function l(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=A(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=A(n,"field",e);if(i>=0&&n.splice(i,1),i=A(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=V(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=V(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(s):n.after('
'+s+"
"),r.ctrl.errorMessageVisible=!0):(u.html(""),r.ctrl.errorMessageVisible=void 0)}function b(e,t){var r,i=this,s=!0,l=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+(n&&n.params?String.format(a,n.params):a):p.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+o:p.message+=s+o,O(i,e,p.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=A(z,"fieldName",e.attr("name"));return u>=0?z[u]=l:z.push(l),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=l.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[l]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,p,d)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var l=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=M(t.condition[0],s,l),d=M(t.condition[1],s,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=M(t.condition,s,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)s=!!d;else{if("object"!=typeof d)throw u;s=!!d.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return s}function H(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=M(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=M(p.condition,d.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=p.message;p.altText&&p.altText.length>0&&(o=p.altText.replace("alt=","")),a(o).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,i,!0)})}d.$setValidity("validation",i)}},!0),i}function I(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(i))n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var o=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=s,X.prototype.getGlobalOptions=l,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e){var o=this,t="",a=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var n=0,i=e.$validationSummary.length;n0&&("function"==typeof l.ctrl.$setTouched&&l.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:l.isValid,obj:l}))}return a}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a Date: Thu, 19 Jan 2017 12:27:08 -0500 Subject: [PATCH 24/60] Rename errorMessageVisible to isErrorMessageVisible --- bower.json | 2 +- changelog.txt | 1 + dist/angular-validation.min.js | 6 +++--- package.json | 2 +- readme.md | 2 +- src/validation-common.js | 4 ++-- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/bower.json b/bower.json index a6df3a1..71862ca 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.14", + "version": "1.5.15", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index e4f5374..0e76159 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.15 (2017-01-19) Rename errorMessageVisible to isErrorMessageVisible. 1.5.14 (2017-01-18) Added errorMessageVisible at updateErrorMsg this help to know when the error message is displayed or not. 1.5.13 (2016-12-29) Make sure element exist before looking for `isValidationCancelled`, issue #139 1.5.12 (2016-12-15) Fix a small issue introduced by last commit (Angular Form overwritten with simple object in some rare occasions). diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 1332e12..f1cf534 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.5.14 + * @version: 1.5.15 * @license: MIT - * @build: Wed Jan 18 2017 23:22:10 GMT-0500 (Eastern Standard Time) + * @build: Thu Jan 19 2017 12:26:45 GMT-0500 (Eastern Standard Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:h.typingLimit,s=h.getFormElementByName(l.$name);if(Array.isArray(i)){if($=[],O="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():(h.validate(i,!1),h.isFieldRequired()||A||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||h.isFieldRequired()||A)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=h.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=h.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):(h.updateErrorMsg(""),e.cancel(b),b=e(function(){d=h.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&($.push(n),parseInt(e)===i-1&&$.forEach(function(a){a.then(function(a){switch(F){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){O.length>0&&g.displayOnlyLastErrorMsg?O="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):O+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),h.updateErrorMsg(O,{isValid:!1}),h.addToValidationSummary(a.formElmObj,O)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=h.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&h.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),h.removeFromValidationSummary(j);var a=h.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=h.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),h.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&h.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=h.getFormElementByName(l.$name);h.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),h.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",h.validate(a,!1));var e=h.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,h=new i(n,t,r,l),O="",$=[],E=[],g=h.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,A=r.hasOwnProperty("validateOnEmpty")?h.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,F=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),h.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{h.defineValidation(),p();var e=h.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t&&t.hasOwnProperty("isValidationCancelled")){var n=o(i);w&&h.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}})}}}]); -angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=A(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Q[o]=l:Q.push(l)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=V(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs[u]?K.controllerAs[u]:e.elm.controller()[u];p&&(p.$validationSummary=V(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function s(e){return e?V(z,"formName",e):z}function l(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=A(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=A(n,"field",e);if(i>=0&&n.splice(i,1),i=A(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=V(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=V(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(s):n.after('
'+s+"
"),r.ctrl.errorMessageVisible=!0):(u.html(""),r.ctrl.errorMessageVisible=void 0)}function b(e,t){var r,i=this,s=!0,l=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+(n&&n.params?String.format(a,n.params):a):p.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+o:p.message+=s+o,O(i,e,p.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=A(z,"fieldName",e.attr("name"));return u>=0?z[u]=l:z.push(l),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=l.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[l]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,p,d)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var l=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=M(t.condition[0],s,l),d=M(t.condition[1],s,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=M(t.condition,s,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)s=!!d;else{if("object"!=typeof d)throw u;s=!!d.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return s}function H(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=M(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=M(p.condition,d.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=p.message;p.altText&&p.altText.length>0&&(o=p.altText.replace("alt=","")),a(o).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,i,!0)})}d.$setValidity("validation",i)}},!0),i}function I(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(i))n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var o=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=s,X.prototype.getGlobalOptions=l,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); +angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=A(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Q[o]=l:Q.push(l)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=V(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs[u]?K.controllerAs[u]:e.elm.controller()[u];p&&(p.$validationSummary=V(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function s(e){return e?V(z,"formName",e):z}function l(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=A(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=A(n,"field",e);if(i>=0&&n.splice(i,1),i=A(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=V(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=V(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(s):n.after('
'+s+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,s=!0,l=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+(n&&n.params?String.format(a,n.params):a):p.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+o:p.message+=s+o,O(i,e,p.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=A(z,"fieldName",e.attr("name"));return u>=0?z[u]=l:z.push(l),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=l.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[l]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,p,d)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var l=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=M(t.condition[0],s,l),d=M(t.condition[1],s,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=M(t.condition,s,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)s=!!d;else{if("object"!=typeof d)throw u;s=!!d.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return s}function H(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=M(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=M(p.condition,d.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=p.message;p.altText&&p.altText.length>0&&(o=p.altText.replace("alt=","")),a(o).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,i,!0)})}d.$setValidity("validation",i)}},!0),i}function I(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(i))n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var o=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=s,X.prototype.getGlobalOptions=l,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e){var o=this,t="",a=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var n=0,i=e.$validationSummary.length;n0&&("function"==typeof l.ctrl.$setTouched&&l.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:l.isValid,obj:l}))}return a}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a not exist then create it, else udpate the text if (!_globalOptions.hideErrorUnderInputs && !!attrs && !attrs.isValid && (isSubmitted || self.ctrl.$dirty || self.ctrl.$touched || self.ctrl.revalidateCalled)) { (errorElm.length > 0) ? errorElm.html(errorMsg) : elm.after('
' + errorMsg + '
'); - self.ctrl.errorMessageVisible = true; + self.ctrl.isErrorMessageVisible = true; } else { errorElm.html(''); // element is pristine or no validation applied, error message has to be blank - self.ctrl.errorMessageVisible = undefined; + self.ctrl.isErrorMessageVisible = undefined; } } From 6d99a537d78d47f3efc115abf24056cdd9b4eb78 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Thu, 19 Jan 2017 14:06:00 -0500 Subject: [PATCH 25/60] typo --- changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 0e76159..99a9b6b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,6 @@ Angular-Validation change logs -1.5.15 (2017-01-19) Rename errorMessageVisible to isErrorMessageVisible. +1.5.15 (2017-01-19) Rename errorMessageVisible flag to isErrorMessageVisible. 1.5.14 (2017-01-18) Added errorMessageVisible at updateErrorMsg this help to know when the error message is displayed or not. 1.5.13 (2016-12-29) Make sure element exist before looking for `isValidationCancelled`, issue #139 1.5.12 (2016-12-15) Fix a small issue introduced by last commit (Angular Form overwritten with simple object in some rare occasions). From 96bc98f9ad5797b97838478e3e8d70614a477fb8 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Tue, 24 Jan 2017 14:28:46 -0500 Subject: [PATCH 26/60] Fix issue where empty Form Controller was throwing an error --- bower.json | 2 +- dist/angular-validation.min.js | 6 +++--- gulpfile.js | 2 +- package.json | 2 +- readme.md | 2 +- src/validation-common.js | 5 ++++- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bower.json b/bower.json index 71862ca..056b698 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.15", + "version": "1.5.16", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index f1cf534..d41c7be 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.5.15 + * @version: 1.5.16 * @license: MIT - * @build: Thu Jan 19 2017 12:26:45 GMT-0500 (Eastern Standard Time) + * @build: Tue Jan 24 2017 13:50:01 GMT-0500 (Eastern Standard Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:h.typingLimit,s=h.getFormElementByName(l.$name);if(Array.isArray(i)){if($=[],O="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():(h.validate(i,!1),h.isFieldRequired()||A||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||h.isFieldRequired()||A)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=h.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=h.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):(h.updateErrorMsg(""),e.cancel(b),b=e(function(){d=h.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&($.push(n),parseInt(e)===i-1&&$.forEach(function(a){a.then(function(a){switch(F){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){O.length>0&&g.displayOnlyLastErrorMsg?O="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):O+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),h.updateErrorMsg(O,{isValid:!1}),h.addToValidationSummary(a.formElmObj,O)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=h.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&h.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),h.removeFromValidationSummary(j);var a=h.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=h.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),h.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&h.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=h.getFormElementByName(l.$name);h.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),h.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",h.validate(a,!1));var e=h.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,h=new i(n,t,r,l),O="",$=[],E=[],g=h.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,A=r.hasOwnProperty("validateOnEmpty")?h.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,F=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),h.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{h.defineValidation(),p();var e=h.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t&&t.hasOwnProperty("isValidationCancelled")){var n=o(i);w&&h.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}})}}}]); -angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=A(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Q[o]=l:Q.push(l)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=V(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs[u]?K.controllerAs[u]:e.elm.controller()[u];p&&(p.$validationSummary=V(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function s(e){return e?V(z,"formName",e):z}function l(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=A(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=A(n,"field",e);if(i>=0&&n.splice(i,1),i=A(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=V(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=V(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(s):n.after('
'+s+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,s=!0,l=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+(n&&n.params?String.format(a,n.params):a):p.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+o:p.message+=s+o,O(i,e,p.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=A(z,"fieldName",e.attr("name"));return u>=0?z[u]=l:z.push(l),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=l.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[l]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,p,d)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var l=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=M(t.condition[0],s,l),d=M(t.condition[1],s,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=M(t.condition,s,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)s=!!d;else{if("object"!=typeof d)throw u;s=!!d.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return s}function H(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=M(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=M(p.condition,d.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=p.message;p.altText&&p.altText.length>0&&(o=p.altText.replace("alt=","")),a(o).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,i,!0)})}d.$setValidity("validation",i)}},!0),i}function I(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(i))n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var o=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=s,X.prototype.getGlobalOptions=l,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); +angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=V(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Q[o]=l:Q.push(l)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,d=K.controllerAs&&K.controllerAs[u]?K.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;d&&(d.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var d=a.split("|");if(d){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=d.length;p=0,g=[];f?(g=d[p].substring(0,c-1).split(":"),g.push(d[p].substring(c))):g=d[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function s(e){return e?A(z,"formName",e):z}function l(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function d(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=V(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=V(n,"field",e);if(i>=0&&n.splice(i,1),i=V(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=p(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var d=r.validatorAttrs.validationErrorTo.charAt(0),p="."===d||"#"===d?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(p))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(s):n.after('
'+s+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,s=!0,l=!0,u=0,d={message:""};"undefined"==typeof e&&(e="");for(var p=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(p),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){d.message.length>0&&K.displayOnlyLastErrorMsg?d.message=s+(n&&n.params?String.format(a,n.params):a):d.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,d.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);d.message.length>0&&K.displayOnlyLastErrorMsg?d.message=s+o:d.message+=s+o,O(i,e,d.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=V(z,"fieldName",e.attr("name"));return u>=0?z[u]=l:z.push(l),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var d=l.split(".");return t.scope[d[0]][d[1]]=u}return t.scope[l]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,d=i&&3===i.length?i[1]:0,p=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,d,p)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var l=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),d=M(t.condition[0],s,l),p=M(t.condition[1],s,u);r=d&&p}else{var m=F(t.params[0],o).getTime();r=M(t.condition,s,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var d=a.params[0],p=f(r,d);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw u;s=!!p.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof p)throw u}return s}function H(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),d=t,p=r.ctrl,m=o(r.ctrl.$name);return i=M(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=M(d.condition,p.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=d.message;d.altText&&d.altText.length>0&&(o=d.altText.replace("alt=","")),a(o).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(d&&d.params?String.format(e,d.params):e),O(r,m,n.message,i,!0)})}p.$setValidity("validation",i)}},!0),i}function I(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],d=f(a,u);if(Y.length>1)for(;Y.length>0;){var p=Y.pop();"function"==typeof p.abort&&p.abort()}if(Y.push(d),!d||"function"!=typeof d.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){d.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(i))n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var o=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=p(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=s,X.prototype.getGlobalOptions=l,X.prototype.isFieldRequired=d,X.prototype.initialize=u,X.prototype.mergeObjects=p,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e){var o=this,t="",a=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var n=0,i=e.$validationSummary.length;n0&&("function"==typeof l.ctrl.$setTouched&&l.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:l.isValid,obj:l}))}return a}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a= 0 ? form.$name.split('.')[1] : form.$name; - var ctrlForm = (!!_globalOptions.controllerAs[formName]) ? _globalOptions.controllerAs[formName] : self.elm.controller()[formName]; + var ctrlForm = (!!_globalOptions.controllerAs && !!_globalOptions.controllerAs[formName]) + ? _globalOptions.controllerAs[formName] + : ((typeof self.elm.controller() !== "undefined") ? self.elm.controller()[formName] : null); + if(!!ctrlForm) { ctrlForm.$validationSummary = arrayFindObjects(_validationSummary, 'formName', form.$name); } From b0c696be9e9b1427190fba544fdd0293fcb00bc6 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Fri, 10 Mar 2017 00:05:40 -0500 Subject: [PATCH 27/60] Add silent mode to checkFormValidity function --- .gitignore | 2 ++ .npmignore | 4 +++- bower.json | 2 +- dist/angular-validation.min.js | 8 ++++---- package.json | 2 +- readme.md | 2 +- src/validation-common.js | 2 +- src/validation-service.js | 7 ++++--- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 088c748..06ab436 100644 --- a/.gitignore +++ b/.gitignore @@ -222,3 +222,5 @@ pip-log.txt #Mr Developer .mr.developer.cfg +yarn-error.log +yarn.lock \ No newline at end of file diff --git a/.npmignore b/.npmignore index 087b123..9a1941d 100644 --- a/.npmignore +++ b/.npmignore @@ -6,4 +6,6 @@ templates/ .gitignore app.js gulpfile.js -index.html \ No newline at end of file +index.html +yarn-error.log +yarn.lock \ No newline at end of file diff --git a/bower.json b/bower.json index 056b698..cb7129a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.16", + "version": "1.5.17", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index d41c7be..b6623ad 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.5.16 + * @version: 1.5.17 * @license: MIT - * @build: Tue Jan 24 2017 13:50:01 GMT-0500 (Eastern Standard Time) + * @build: Fri Mar 10 2017 00:02:53 GMT-0500 (Eastern Standard Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:h.typingLimit,s=h.getFormElementByName(l.$name);if(Array.isArray(i)){if($=[],O="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():(h.validate(i,!1),h.isFieldRequired()||A||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||h.isFieldRequired()||A)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=h.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=h.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):(h.updateErrorMsg(""),e.cancel(b),b=e(function(){d=h.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&($.push(n),parseInt(e)===i-1&&$.forEach(function(a){a.then(function(a){switch(F){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){O.length>0&&g.displayOnlyLastErrorMsg?O="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):O+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),h.updateErrorMsg(O,{isValid:!1}),h.addToValidationSummary(a.formElmObj,O)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=h.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&h.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),h.removeFromValidationSummary(j);var a=h.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=h.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),h.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&h.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=h.getFormElementByName(l.$name);h.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),h.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",h.validate(a,!1));var e=h.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,h=new i(n,t,r,l),O="",$=[],E=[],g=h.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,A=r.hasOwnProperty("validateOnEmpty")?h.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,F=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),h.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{h.defineValidation(),p();var e=h.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t&&t.hasOwnProperty("isValidationCancelled")){var n=o(i);w&&h.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}})}}}]); -angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=V(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Q[o]=l:Q.push(l)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,d=K.controllerAs&&K.controllerAs[u]?K.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;d&&(d.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var d=a.split("|");if(d){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=d.length;p=0,g=[];f?(g=d[p].substring(0,c-1).split(":"),g.push(d[p].substring(c))):g=d[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function s(e){return e?A(z,"formName",e):z}function l(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function d(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=V(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=V(n,"field",e);if(i>=0&&n.splice(i,1),i=V(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=p(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var d=r.validatorAttrs.validationErrorTo.charAt(0),p="."===d||"#"===d?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(p))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(s):n.after('
'+s+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,s=!0,l=!0,u=0,d={message:""};"undefined"==typeof e&&(e="");for(var p=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(p),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){d.message.length>0&&K.displayOnlyLastErrorMsg?d.message=s+(n&&n.params?String.format(a,n.params):a):d.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,d.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);d.message.length>0&&K.displayOnlyLastErrorMsg?d.message=s+o:d.message+=s+o,O(i,e,d.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=V(z,"fieldName",e.attr("name"));return u>=0?z[u]=l:z.push(l),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var d=l.split(".");return t.scope[d[0]][d[1]]=u}return t.scope[l]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,d=i&&3===i.length?i[1]:0,p=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,d,p)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var l=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),d=M(t.condition[0],s,l),p=M(t.condition[1],s,u);r=d&&p}else{var m=F(t.params[0],o).getTime();r=M(t.condition,s,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var d=a.params[0],p=f(r,d);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw u;s=!!p.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof p)throw u}return s}function H(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),d=t,p=r.ctrl,m=o(r.ctrl.$name);return i=M(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=M(d.condition,p.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=d.message;d.altText&&d.altText.length>0&&(o=d.altText.replace("alt=","")),a(o).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(d&&d.params?String.format(e,d.params):e),O(r,m,n.message,i,!0)})}p.$setValidity("validation",i)}},!0),i}function I(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],d=f(a,u);if(Y.length>1)for(;Y.length>0;){var p=Y.pop();"function"==typeof p.abort&&p.abort()}if(Y.push(d),!d||"function"!=typeof d.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){d.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(i))n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var o=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=p(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=s,X.prototype.getGlobalOptions=l,X.prototype.isFieldRequired=d,X.prototype.initialize=u,X.prototype.mergeObjects=p,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); +angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=V(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Q[o]=l:Q.push(l)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,d=K.controllerAs&&K.controllerAs[u]?K.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;d&&(d.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var d=a.split("|");if(d){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=d.length;p=0,g=[];f?(g=d[p].substring(0,c-1).split(":"),g.push(d[p].substring(c))):g=d[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function s(e){return e?A(z,"formName",e):z}function l(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function d(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=V(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=V(n,"field",e);if(i>=0&&n.splice(i,1),i=V(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=p(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var d=r.validatorAttrs.validationErrorTo.charAt(0),p="."===d||"#"===d?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(p))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(s):n.after('
'+s+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,s=!0,l=!0,u=0,d={message:""};"undefined"==typeof e&&(e="");for(var p=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(p),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){d.message.length>0&&K.displayOnlyLastErrorMsg?d.message=s+(n&&n.params?String.format(a,n.params):a):d.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,d.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);d.message.length>0&&K.displayOnlyLastErrorMsg?d.message=s+o:d.message+=s+o,O(i,e,d.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=V(z,"fieldName",e.attr("name"));return u>=0?z[u]=l:z.push(l),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var d=l.split(".");return t.scope[d[0]][d[1]]=u}return t.scope[l]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,d=i&&3===i.length?i[1]:0,p=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,d,p)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var l=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),d=M(t.condition[0],s,l),p=M(t.condition[1],s,u);r=d&&p}else{var m=F(t.params[0],o).getTime();r=M(t.condition,s,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var d=a.params[0],p=f(r,d);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw u;s=!!p.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof p)throw u}return s}function H(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),d=t,p=r.ctrl,m=o(r.ctrl.$name);return i=M(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=M(d.condition,p.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=d.message;d.altText&&d.altText.length>0&&(o=d.altText.replace("alt=","")),a(o).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(d&&d.params?String.format(e,d.params):e),O(r,m,n.message,i,!0)})}p.$setValidity("validation",i)}},!0),i}function I(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],d=f(a,u);if(Y.length>1)for(;Y.length>0;){var p=Y.pop();p&&"function"==typeof p.abort&&p.abort()}if(Y.push(d),!d||"function"!=typeof d.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){d.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(i))n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var o=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=p(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=s,X.prototype.getGlobalOptions=l,X.prototype.isFieldRequired=d,X.prototype.initialize=u,X.prototype.mergeObjects=p,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; -angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e){var o=this,t="",a=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var n=0,i=e.$validationSummary.length;n0&&("function"==typeof l.ctrl.$setTouched&&l.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:l.isValid,obj:l}))}return a}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a0&&("function"!=typeof m.ctrl.$setTouched||o||m.ctrl.$setTouched(),t.commonObj.updateErrorMsg(e.$validationSummary[i].message,{isSubmitted:!o,isValid:m.isValid,obj:m}))}return n}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a 1) { while (_remotePromises.length > 0) { var previousPromise = _remotePromises.pop(); - if (typeof previousPromise.abort === "function") { + if (!!previousPromise && typeof previousPromise.abort === "function") { previousPromise.abort(); // run the abort if user declared it } } diff --git a/src/validation-service.js b/src/validation-service.js index 5d3204b..04a8c57 100644 --- a/src/validation-service.js +++ b/src/validation-service.js @@ -146,9 +146,10 @@ angular /** Check the form validity (can be called by an empty ValidationService and used by both Directive/Service) * Loop through Validation Summary and if any errors found then display them and return false on current function * @param object Angular Form or Scope Object + * @param bool silently, do a form validation silently * @return bool isFormValid */ - function checkFormValidity(obj) { + function checkFormValidity(obj, silently) { var self = this; var ctrl, elm, elmName = '', isValid = true; if(typeof obj === "undefined" || typeof obj.$validationSummary === "undefined") { @@ -166,10 +167,10 @@ angular if(!!formElmObj && !!formElmObj.elm && formElmObj.elm.length > 0) { // make the element as it was touched for CSS, only works in AngularJS 1.3+ - if (typeof formElmObj.ctrl.$setTouched === "function") { + if (typeof formElmObj.ctrl.$setTouched === "function" && !silently) { formElmObj.ctrl.$setTouched(); } - self.commonObj.updateErrorMsg(obj.$validationSummary[i].message, { isSubmitted: true, isValid: formElmObj.isValid, obj: formElmObj }); + self.commonObj.updateErrorMsg(obj.$validationSummary[i].message, { isSubmitted: (!!silently ? false : true), isValid: formElmObj.isValid, obj: formElmObj }); } } } From 45fc0e776031cc74d82c8d136472b88cd1b90f50 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Fri, 10 Mar 2017 00:12:21 -0500 Subject: [PATCH 28/60] Update change log --- changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index 99a9b6b..3ef321b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,7 @@ Angular-Validation change logs +1.5.17 (2017-03-10) Add silent mode to checkFormValidity function +1.5.16 (2017-01-24) Fix issue where empty Form Controller was throwing an error 1.5.15 (2017-01-19) Rename errorMessageVisible flag to isErrorMessageVisible. 1.5.14 (2017-01-18) Added errorMessageVisible at updateErrorMsg this help to know when the error message is displayed or not. 1.5.13 (2016-12-29) Make sure element exist before looking for `isValidationCancelled`, issue #139 From cf135c2dab8d973d7b2a7948bfca8114c534d28e Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Sun, 26 Mar 2017 23:50:57 -0400 Subject: [PATCH 29/60] typo - fix markdown changes in Github --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 8b476a3..560e036 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -#Angular Validation (Directive / Service) +# Angular Validation (Directive / Service) `Version: 1.5.17` ### Forms Validation with Angular made easy! ##### (Concept comes from the amazing Laravel) @@ -129,10 +129,10 @@ When used with IIS, you will need to map the JSON type ``` -###License +### License [MIT License](http://www.opensource.org/licenses/mit-license.php) -###Available Validator Rules +### Available Validator Rules All validators are written as `snake_case` but it's up to the user's taste and could also be used as `camelCase`. So for example `alpha_dash_spaces` and `alphaDashSpaces` are both equivalent. ##### NOTE: on an `input type="number"`, the `+` sign is an invalid character (browser restriction) even if you are using a `signed` validator. If you really wish to use the `+`, then change your input to a `type="text"`. From 84607ca6e71a0ed427534a2302d8abdd5e09aa35 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Fri, 31 Mar 2017 15:03:29 -0400 Subject: [PATCH 30/60] Fix disabled="false" as attribute to run validation evaluate the disabled="false" attribute value in Angular-Validation so that the validation kicks in when this value is set to "false". This was problem found with the 3rd party library nya-bootstrap-select --- bower.json | 2 +- changelog.txt | 1 + dist/angular-validation.min.js | 10 ++--- index.html | 6 +-- .../addon-3rdParty-withScope/index.html | 2 +- more-examples/addon-3rdParty/index.html | 2 +- package.json | 2 +- src/validation-common.js | 38 ++++++++++++++++--- src/validation-directive.js | 7 +++- src/validation-service.js | 7 +++- 10 files changed, 56 insertions(+), 21 deletions(-) diff --git a/bower.json b/bower.json index cb7129a..835b098 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.17", + "version": "1.5.18", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index 3ef321b..31cca7e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.18 (2017-03-31) Fix disabled="false" as attribute to run validation. 1.5.17 (2017-03-10) Add silent mode to checkFormValidity function 1.5.16 (2017-01-24) Fix issue where empty Form Controller was throwing an error 1.5.15 (2017-01-19) Rename errorMessageVisible flag to isErrorMessageVisible. diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index b6623ad..a498e12 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.5.17 + * @version: 1.5.18 * @license: MIT - * @build: Fri Mar 10 2017 00:02:53 GMT-0500 (Eastern Standard Time) + * @build: Fri Mar 31 2017 14:32:56 GMT-0400 (Eastern Daylight Time) */ -angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:h.typingLimit,s=h.getFormElementByName(l.$name);if(Array.isArray(i)){if($=[],O="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():(h.validate(i,!1),h.isFieldRequired()||A||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||h.isFieldRequired()||A)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=h.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=h.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):(h.updateErrorMsg(""),e.cancel(b),b=e(function(){d=h.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&($.push(n),parseInt(e)===i-1&&$.forEach(function(a){a.then(function(a){switch(F){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){O.length>0&&g.displayOnlyLastErrorMsg?O="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):O+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),h.updateErrorMsg(O,{isValid:!1}),h.addToValidationSummary(a.formElmObj,O)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=h.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&h.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),h.removeFromValidationSummary(j);var a=h.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=h.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),h.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&h.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=h.getFormElementByName(l.$name);h.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),h.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",h.validate(a,!1));var e=h.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,h=new i(n,t,r,l),O="",$=[],E=[],g=h.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,A=r.hasOwnProperty("validateOnEmpty")?h.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,F=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),h.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{h.defineValidation(),p();var e=h.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t&&t.hasOwnProperty("isValidationCancelled")){var n=o(i);w&&h.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}})}}}]); -angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=V(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Q[o]=l:Q.push(l)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,d=K.controllerAs&&K.controllerAs[u]?K.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;d&&(d.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var d=a.split("|");if(d){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=d.length;p=0,g=[];f?(g=d[p].substring(0,c-1).split(":"),g.push(d[p].substring(c))):g=d[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function s(e){return e?A(z,"formName",e):z}function l(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function d(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=V(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=V(n,"field",e);if(i>=0&&n.splice(i,1),i=V(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=p(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var d=r.validatorAttrs.validationErrorTo.charAt(0),p="."===d||"#"===d?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(p))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(s):n.after('
'+s+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,s=!0,l=!0,u=0,d={message:""};"undefined"==typeof e&&(e="");for(var p=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(p),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){d.message.length>0&&K.displayOnlyLastErrorMsg?d.message=s+(n&&n.params?String.format(a,n.params):a):d.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,d.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);d.message.length>0&&K.displayOnlyLastErrorMsg?d.message=s+o:d.message+=s+o,O(i,e,d.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=V(z,"fieldName",e.attr("name"));return u>=0?z[u]=l:z.push(l),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var d=l.split(".");return t.scope[d[0]][d[1]]=u}return t.scope[l]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,d=i&&3===i.length?i[1]:0,p=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,d,p)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var l=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),d=M(t.condition[0],s,l),p=M(t.condition[1],s,u);r=d&&p}else{var m=F(t.params[0],o).getTime();r=M(t.condition,s,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var d=a.params[0],p=f(r,d);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw u;s=!!p.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof p)throw u}return s}function H(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),d=t,p=r.ctrl,m=o(r.ctrl.$name);return i=M(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=M(d.condition,p.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=d.message;d.altText&&d.altText.length>0&&(o=d.altText.replace("alt=","")),a(o).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(d&&d.params?String.format(e,d.params):e),O(r,m,n.message,i,!0)})}p.$setValidity("validation",i)}},!0),i}function I(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],d=f(a,u);if(Y.length>1)for(;Y.length>0;){var p=Y.pop();p&&"function"==typeof p.abort&&p.abort()}if(Y.push(d),!d||"function"!=typeof d.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){d.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(i))n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var o=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=p(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=s,X.prototype.getGlobalOptions=l,X.prototype.isFieldRequired=d,X.prototype.initialize=u,X.prototype.mergeObjects=p,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); +angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||A||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||A)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(F){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&$.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&$.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,A=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,F=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){var e=""===a||("boolean"==typeof a?a:"undefined"!=typeof a&&n.$eval(a));e===!0?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t&&t.hasOwnProperty("isValidationCancelled")){var n=o(i);w&&$.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}})}}}]); +angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=V(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Q[o]=l:Q.push(l)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs&&K.controllerAs[u]?K.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;p&&(p.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function s(e){return e?A(z,"formName",e):z}function l(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=V(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=V(n,"field",e);if(i>=0&&n.splice(i,1),i=V(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(s):n.after('
'+s+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,s=!0,l=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+(n&&n.params?String.format(a,n.params):a):p.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+o:p.message+=s+o,O(i,e,p.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=V(z,"fieldName",e.attr("name"));return u>=0?z[u]=l:z.push(l),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=l.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[l]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,p,d)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var l=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=M(t.condition[0],s,l),d=M(t.condition[1],s,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=M(t.condition,s,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)s=!!d;else{if("object"!=typeof d)throw u;s=!!d.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return s}function H(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=M(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=M(p.condition,d.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=p.message;p.altText&&p.altText.length>0&&(o=p.altText.replace("alt=","")),a(o).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,i,!0)})}d.$setValidity("validation",i)}},!0),i}function I(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();d&&"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled,o=r.elm.prop("disabled"),s=""===o||("boolean"==typeof o?o:"undefined"!=typeof o&&r.scope.$eval(o)),l=""===i||("boolean"==typeof i?i:"undefined"!=typeof i&&r.scope.$eval(i));if(s||l)n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var u=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&u.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=s,X.prototype.getGlobalOptions=l,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; -angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e,o){var t=this,a="",n=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var i=0,l=e.$validationSummary.length;i0&&("function"!=typeof m.ctrl.$setTouched||o||m.ctrl.$setTouched(),t.commonObj.updateErrorMsg(e.$validationSummary[i].message,{isSubmitted:!o,isValid:m.isValid,obj:m}))}return n}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a0&&("function"!=typeof m.ctrl.$setTouched||o||m.ctrl.$setTouched(),t.commonObj.updateErrorMsg(e.$validationSummary[i].message,{isSubmitted:!o,isValid:m.isValid,obj:m}))}return n}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;aAngular-Validation Directive|Service (ghiscoding) - + - - +
diff --git a/more-examples/addon-3rdParty-withScope/index.html b/more-examples/addon-3rdParty-withScope/index.html index 8748bea..c331e76 100644 --- a/more-examples/addon-3rdParty-withScope/index.html +++ b/more-examples/addon-3rdParty-withScope/index.html @@ -53,7 +53,7 @@ - + diff --git a/more-examples/addon-3rdParty/index.html b/more-examples/addon-3rdParty/index.html index fee3533..9377e23 100644 --- a/more-examples/addon-3rdParty/index.html +++ b/more-examples/addon-3rdParty/index.html @@ -119,7 +119,7 @@

ERRORS!

- + diff --git a/package.json b/package.json index a0aed52..4adf768 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.17", + "version": "1.5.18", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": "dist/angular-validation.min", diff --git a/src/validation-common.js b/src/validation-common.js index 972d459..0cfdba6 100644 --- a/src/validation-common.js +++ b/src/validation-common.js @@ -153,10 +153,10 @@ angular // also save it inside controllerAs form (if found) if (!!form && !!form.$name) { var formName = form.$name.indexOf('.') >= 0 ? form.$name.split('.')[1] : form.$name; - var ctrlForm = (!!_globalOptions.controllerAs && !!_globalOptions.controllerAs[formName]) - ? _globalOptions.controllerAs[formName] + var ctrlForm = (!!_globalOptions.controllerAs && !!_globalOptions.controllerAs[formName]) + ? _globalOptions.controllerAs[formName] : ((typeof self.elm.controller() !== "undefined") ? self.elm.controller()[formName] : null); - + if(!!ctrlForm) { ctrlForm.$validationSummary = arrayFindObjects(_validationSummary, 'formName', form.$name); } @@ -542,9 +542,22 @@ angular validator = validatorAutoDetectType(validator, strValue); } - // get the ngDisabled attribute if found + // get the disabled & ngDisabled attributes if found + var elmAttrDisabled = self.elm.prop("disabled"); var elmAttrNgDisabled = (!!self.attrs) ? self.attrs.ngDisabled : self.validatorAttrs.ngDisabled; + var isDisabled = (elmAttrDisabled === "") + ? true + : (typeof elmAttrDisabled === "boolean") + ? elmAttrDisabled + : (typeof elmAttrDisabled !== "undefined") ? self.scope.$eval(elmAttrDisabled) : false; + + var isNgDisabled = (elmAttrNgDisabled === "") + ? true + : (typeof elmAttrNgDisabled === "boolean") + ? elmAttrNgDisabled + : (typeof elmAttrNgDisabled !== "undefined") ? self.scope.$eval(elmAttrNgDisabled) : false; + // now that we have a Validator type, we can now validate our value // there is multiple type that can influence how the value will be validated switch(validator.type) { @@ -569,7 +582,7 @@ angular } // not required and not filled is always valid & 'disabled', 'ng-disabled' elements should always be valid - if ((!self.bFieldRequired && !strValue && !_validateOnEmpty) || (!!self.elm.prop("disabled") || !!self.scope.$eval(elmAttrNgDisabled))) { + if ((!self.bFieldRequired && !strValue && !_validateOnEmpty) || (isDisabled || isNgDisabled)) { isConditionValid = true; } @@ -1404,9 +1417,22 @@ angular // get the ngDisabled attribute if found var elmAttrNgDisabled = (!!self.attrs) ? self.attrs.ngDisabled : self.validatorAttrs.ngDisabled; + var elmAttrDisabled = self.elm.prop("disabled"); + + var isDisabled = (elmAttrDisabled === "") + ? true + : (typeof elmAttrDisabled === "boolean") + ? elmAttrDisabled + : (typeof elmAttrDisabled !== "undefined") ? self.scope.$eval(elmAttrDisabled) : false; + + var isNgDisabled = (elmAttrNgDisabled === "") + ? true + : (typeof elmAttrNgDisabled === "boolean") + ? elmAttrNgDisabled + : (typeof elmAttrNgDisabled !== "undefined") ? self.scope.$eval(elmAttrNgDisabled) : false; // a 'disabled' element should always be valid, there is no need to validate it - if (!!self.elm.prop("disabled") || !!self.scope.$eval(elmAttrNgDisabled)) { + if (isDisabled || isNgDisabled) { isValid = true; } else { // before running Regex test, we'll make sure that an input of type="number" doesn't hold invalid keyboard chars, if true skip Regex diff --git a/src/validation-directive.js b/src/validation-directive.js index fd5e4bb..5ff9517 100644 --- a/src/validation-directive.js +++ b/src/validation-directive.js @@ -48,7 +48,12 @@ // watch the `disabled` attribute for changes // if it become disabled then skip validation else it becomes enable then we need to revalidate it attrs.$observe("disabled", function(disabled) { - if (disabled) { + var isDisabled = (disabled === "") + ? true + : (typeof disabled === "boolean") ? disabled + : (typeof disabled !== "undefined") ? scope.$eval(disabled) : false; + + if (isDisabled === true) { // Turn off validation when element is disabled & remove it from validation summary cancelValidation(); commonObj.removeFromValidationSummary(_elmName); diff --git a/src/validation-service.js b/src/validation-service.js index 04a8c57..6ce3f73 100644 --- a/src/validation-service.js +++ b/src/validation-service.js @@ -547,7 +547,12 @@ angular // use a timeout so that the digest of removing the `disabled` attribute on the DOM is completed // because commonObj.validate() checks for both the `disabled` and `ng-disabled` attribute so it basically fails without the $timeout because of the digest $timeout(function() { - if (disabled) { + var isDisabled = (disabled === "") + ? true + : (typeof disabled === "boolean") ? disabled + : (typeof disabled !== "undefined") ? scope.$eval(disabled) : false; + + if (isDisabled) { // Remove it from validation summary attrs.ctrl.$setValidity('validation', true); self.commonObj.updateErrorMsg('', { isValid: true, obj: formElmObj }); From 8f5ebf0a537c7c563daab95e9612edd8055efdeb Mon Sep 17 00:00:00 2001 From: Jeremy Solt Date: Mon, 17 Apr 2017 19:57:29 -0500 Subject: [PATCH 31/60] Fix revalidate for directive --- src/validation-directive.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/validation-directive.js b/src/validation-directive.js index 5ff9517..3bd2dcc 100644 --- a/src/validation-directive.js +++ b/src/validation-directive.js @@ -100,7 +100,8 @@ ctrl.revalidateCalled = true; var value = ctrl.$modelValue; - if (!!elm && elm.hasOwnProperty("isValidationCancelled")) { + var formElmObj = commonObj.getFormElementByName(ctrl.$name); + if (!!formElmObj && formElmObj.hasOwnProperty("isValidationCancelled")) { // attempt to validate & run validation callback if user requested it var validationPromise = attemptToValidate(value); if(!!_validationCallback) { From d253eab5c35cddd9839d9e6adceeb60932b26916 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Mon, 17 Apr 2017 23:46:09 -0400 Subject: [PATCH 32/60] Fix #150 angularValidation.revalidate problems Thanks to @jsolt for fixing the issue --- bower.json | 2 +- changelog.txt | 1 + dist/angular-validation.min.js | 6 +++--- package.json | 2 +- readme.md | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 835b098..0f464c8 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.18", + "version": "1.5.19", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index 31cca7e..e088f53 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.19 (2017-04-17) Fix #150 angularValidation.revalidate problems 1.5.18 (2017-03-31) Fix disabled="false" as attribute to run validation. 1.5.17 (2017-03-10) Add silent mode to checkFormValidity function 1.5.16 (2017-01-24) Fix issue where empty Form Controller was throwing an error diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index a498e12..618e84c 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.5.18 + * @version: 1.5.19 * @license: MIT - * @build: Fri Mar 31 2017 14:32:56 GMT-0400 (Eastern Daylight Time) + * @build: Mon Apr 17 2017 23:41:06 GMT-0400 (Eastern Daylight Time) */ -angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||A||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||A)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(F){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&$.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&$.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,A=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,F=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){var e=""===a||("boolean"==typeof a?a:"undefined"!=typeof a&&n.$eval(a));e===!0?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t&&t.hasOwnProperty("isValidationCancelled")){var n=o(i);w&&$.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}})}}}]); +angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(A){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&$.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&$.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,A=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){var e=""===a||("boolean"==typeof a?a:"undefined"!=typeof a&&n.$eval(a));e===!0?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue,n=$.getFormElementByName(l.$name);if(n&&n.hasOwnProperty("isValidationCancelled")){var t=o(i);w&&$.runValidationCallbackOnPromise(t,w)}else l.$setValidity("validation",!0)}})}}}]); angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=V(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Q[o]=l:Q.push(l)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs&&K.controllerAs[u]?K.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;p&&(p.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function s(e){return e?A(z,"formName",e):z}function l(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=V(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=V(n,"field",e);if(i>=0&&n.splice(i,1),i=V(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(s):n.after('
'+s+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,s=!0,l=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+(n&&n.params?String.format(a,n.params):a):p.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+o:p.message+=s+o,O(i,e,p.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=V(z,"fieldName",e.attr("name"));return u>=0?z[u]=l:z.push(l),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=l.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[l]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,p,d)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var l=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=M(t.condition[0],s,l),d=M(t.condition[1],s,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=M(t.condition,s,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)s=!!d;else{if("object"!=typeof d)throw u;s=!!d.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return s}function H(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=M(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=M(p.condition,d.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=p.message;p.altText&&p.altText.length>0&&(o=p.altText.replace("alt=","")),a(o).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,i,!0)})}d.$setValidity("validation",i)}},!0),i}function I(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();d&&"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled,o=r.elm.prop("disabled"),s=""===o||("boolean"==typeof o?o:"undefined"!=typeof o&&r.scope.$eval(o)),l=""===i||("boolean"==typeof i?i:"undefined"!=typeof i&&r.scope.$eval(i));if(s||l)n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var u=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&u.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=s,X.prototype.getGlobalOptions=l,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return g=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,$=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);g&&n.commonObj.runValidationCallbackOnPromise(t,g)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e,o){var t=this,a="",n=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var i=0,l=e.$validationSummary.length;i0&&("function"!=typeof m.ctrl.$setTouched||o||m.ctrl.$setTouched(),t.commonObj.updateErrorMsg(e.$validationSummary[i].message,{isSubmitted:!o,isValid:m.isValid,obj:m}))}return n}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a Date: Thu, 20 Apr 2017 12:20:22 -0400 Subject: [PATCH 33/60] Add unminified version and fix #153 bug in validation service --- bower.json | 2 +- dist/angular-validation.js | 3350 ++++++++++++++++++++++++++++++++ dist/angular-validation.min.js | 6 +- gulpfile.js | 12 + package.json | 2 +- readme.md | 2 +- src/validation-service.js | 2 +- 7 files changed, 3369 insertions(+), 7 deletions(-) create mode 100644 dist/angular-validation.js diff --git a/bower.json b/bower.json index 0f464c8..110ecee 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.19", + "version": "1.5.20", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/dist/angular-validation.js b/dist/angular-validation.js new file mode 100644 index 0000000..323f9fc --- /dev/null +++ b/dist/angular-validation.js @@ -0,0 +1,3350 @@ +/** + * Angular-Validation Directive and Service (ghiscoding) + * http://github.com/ghiscoding/angular-validation + * @author: Ghislain B. + * @version: 1.5.20 + * @license: MIT + * @build: Thu Apr 20 2017 12:18:09 GMT-0400 (Eastern Daylight Time) + */ +/** + * Angular-Validation Directive (ghiscoding) + * https://github.com/ghiscoding/angular-validation + * + * @author: Ghislain B. + * @started: 2014-02-04 + * + * @desc: If a field becomes invalid, the text inside the error or
will show up because the error string gets filled + * Though when the field becomes valid then the error message becomes an empty string, + * it will be transparent to the user even though the still exist but becomes invisible since the text is empty. + * + */ + angular + .module('ghiscoding.validation', ['pascalprecht.translate']) + .directive('validation', ['$q', '$timeout', 'ValidationCommon', function($q, $timeout, ValidationCommon) { + return { + restrict: "A", + require: "ngModel", + link: function(scope, elm, attrs, ctrl) { + // create an object of the common validation + var commonObj = new ValidationCommon(scope, elm, attrs, ctrl); + var _arrayErrorMessage = ''; + var _promises = []; + var _timer; + var _watchers = []; + var _globalOptions = commonObj.getGlobalOptions(); + + // Possible element attributes + var _elmName = attrs.name; + var _validationCallback = (attrs.hasOwnProperty('validationCallback')) ? attrs.validationCallback : null; + var _validateOnEmpty = (attrs.hasOwnProperty('validateOnEmpty')) ? commonObj.parseBool(attrs.validateOnEmpty) : !!_globalOptions.validateOnEmpty; + + //-- Possible validation-array attributes + // on a validation array, how many does it require to be valid? + // As soon as 'one' is valid, or does it need 'all' array values to make the input valid? + var _validArrayRequireHowMany = (attrs.hasOwnProperty('validArrayRequireHowMany')) ? attrs.validArrayRequireHowMany : "one"; + var _validationArrayObjprop = (attrs.hasOwnProperty('validationArrayObjprop')) ? attrs.validationArrayObjprop : null; + + // construct the functions, it's just to make the code cleaner and put the functions at bottom + var construct = { + attemptToValidate: attemptToValidate, + cancelValidation : cancelValidation + } + + // create & save watcher inside an array in case we want to deregister it when removing a validator + _watchers.push({ elmName: _elmName, watcherHandler: createWatch() }); + + // watch the `disabled` attribute for changes + // if it become disabled then skip validation else it becomes enable then we need to revalidate it + attrs.$observe("disabled", function(disabled) { + var isDisabled = (disabled === "") + ? true + : (typeof disabled === "boolean") ? disabled + : (typeof disabled !== "undefined") ? scope.$eval(disabled) : false; + + if (isDisabled === true) { + // Turn off validation when element is disabled & remove it from validation summary + cancelValidation(); + commonObj.removeFromValidationSummary(_elmName); + } else { + // revalidate & re-attach the onBlur event + revalidateAndAttachOnBlur(); + } + }); + + // if DOM element gets destroyed, we need to cancel validation, unbind onBlur & remove it from $validationSummary + elm.on('$destroy', function() { + cancelAndUnbindValidation(); + }); + + // watch for a validation attribute changing to empty, if that is the case, unbind everything from it + scope.$watch(function() { + return elm.attr('validation'); + }, function(validation) { + if(typeof validation === "undefined" || validation === '') { + // if validation gets empty, we need to cancel validation, unbind onBlur & remove it from $validationSummary + cancelAndUnbindValidation(); + }else { + // If validation attribute gets filled/re-filled (could be by interpolation) + // we need to redefine the validation so that we can grab the new "validation" element attribute + // and finally revalidate & re-attach the onBlur event + commonObj.defineValidation(); + revalidateAndAttachOnBlur(); + + // if watcher not already exist, then create & save watcher inside an array in case we want to deregister it later + var foundWatcher = commonObj.arrayFindObject(_watchers, 'elmName', ctrl.$name); + if(!foundWatcher) { + _watchers.push({ elmName: _elmName, watcherHandler: createWatch() }); + } + } + }); + + // attach the onBlur event handler on the element + elm.bind('blur', blurHandler); + + // attach the angularValidation.revalidate event handler on the scope + scope.$on('angularValidation.revalidate', function(event, args){ + if (args == ctrl.$name) + { + ctrl.revalidateCalled = true; + var value = ctrl.$modelValue; + + var formElmObj = commonObj.getFormElementByName(ctrl.$name); + if (!!formElmObj && formElmObj.hasOwnProperty("isValidationCancelled")) { + // attempt to validate & run validation callback if user requested it + var validationPromise = attemptToValidate(value); + if(!!_validationCallback) { + commonObj.runValidationCallbackOnPromise(validationPromise, _validationCallback); + } + } + else { + ctrl.$setValidity('validation', true); + } + } + }); + + //---- + // Private functions declaration + //---------------------------------- + + /** Validator function to attach to the element, this will get call whenever the input field is updated + * and is also customizable through the (typing-limit) for which inactivity this.timer will trigger validation. + * @param string value: value of the input field + * @param int typingLimit: when user stop typing, in how much time it will start validating + * @return object validation promise + */ + function attemptToValidate(value, typingLimit) { + var deferred = $q.defer(); + var isValid = false; + + // get the waiting delay time if passed as argument or get it from common Object + var waitingLimit = (typeof typingLimit !== "undefined") ? typingLimit : commonObj.typingLimit; + + // get the form element custom object and use it after + var formElmObj = commonObj.getFormElementByName(ctrl.$name); + + // if the input value is an array (like a 3rd party addons) then attempt to validate + // by exploding the array into individual input values and then validate them one value by one + if(Array.isArray(value)) { + // reset the promises array + _promises = []; + _arrayErrorMessage = ''; + waitingLimit = 0; + + // If we get a filled array, we will explode the array and try to validate each input value independently and + // Else when array is or become empty, we still want to validate it but without waiting time, + // a "required" validation needs to be invalid right away. + // NOTE: because most 3rd party addons support AngularJS older than 1.3, the $touched property on the element is most often not implemented + // but is required for Angular-Validation to properly display error messages and I have to force a $setTouched and by doing so force to show error message instantly on screen. + // unless someone can figure out a better approach that is universal to all addons. I could in fact also use $dirty but even that is most often not implement by adons either. + if(value.length > 0) { + // make the element as it was touched for CSS, only works in AngularJS 1.3+ + if (typeof formElmObj.ctrl.$setTouched === "function") { + formElmObj.ctrl.$setTouched(); + } + return explodeArrayAndAttemptToValidate(value, typeof value); + }else { + waitingLimit = 0; + } + } + + // if a field holds invalid characters which are not numbers inside an `input type="number"`, then it's automatically invalid + // we will still call the `.validate()` function so that it shows also the possible other error messages + if(!!value && !!value.badInput) { + return invalidateBadInputField(); + } + + // pre-validate without any events just to pre-fill our validationSummary with all field errors + // passing False as the 2nd argument to hide errors from being displayed on screen + commonObj.validate(value, false); + + // if field is not required and his value is empty, cancel validation and exit out + if(!commonObj.isFieldRequired() && !_validateOnEmpty && (value === "" || value === null || typeof value === "undefined")) { + cancelValidation(); + deferred.resolve({ isFieldValid: true, formElmObj: formElmObj, value: value }); + return deferred.promise; + }else if(!!formElmObj) { + formElmObj.isValidationCancelled = false; + } + + // invalidate field before doing any validation + if(!!value || commonObj.isFieldRequired() || _validateOnEmpty) { + ctrl.$setValidity('validation', false); + } + + // select(options) will be validated on the spot + if(elm.prop('tagName').toUpperCase() === "SELECT") { + isValid = commonObj.validate(value, true); + ctrl.$setValidity('validation', isValid); + deferred.resolve({ isFieldValid: isValid, formElmObj: formElmObj, value: value }); + return deferred.promise; + } + + // onKeyDown event is the default of Angular, no need to even bind it, it will fall under here anyway + // in case the field is already pre-filled, we need to validate it without looking at the event binding + if(typeof value !== "undefined") { + // when no timer, validate right away without a $timeout. This seems quite important on the array input value check + if(typingLimit === 0) { + isValid = commonObj.validate(value, true); + scope.$evalAsync(ctrl.$setValidity('validation', isValid )); + deferred.resolve({ isFieldValid: isValid, formElmObj: formElmObj, value: value }); + $timeout.cancel(_timer); + }else { + // Start validation only after the user has stopped typing in a field + // everytime a new character is typed, it will cancel/restart the timer & we'll erase any error mmsg + commonObj.updateErrorMsg(''); + $timeout.cancel(_timer); + _timer = $timeout(function() { + isValid = commonObj.validate(value, true); + scope.$evalAsync(ctrl.$setValidity('validation', isValid )); + deferred.resolve({ isFieldValid: isValid, formElmObj: formElmObj, value: value }); + }, waitingLimit); + } + } + + return deferred.promise; + } // attemptToValidate() + + /** Attempt to validate an input value that was previously exploded from the input array + * Each attempt will return a promise but only after reaching the last index, will we analyze the final validation. + * @param string: input value + * @param int: position index + * @param int: size of original array + */ + function attemptToValidateArrayInput(inputValue, index, arraySize) { + var promise = attemptToValidate(inputValue, 0); + if(!!promise && typeof promise.then === "function") { + _promises.push(promise); + + // if we reached the last index + // then loop through all promises to run validation on each array input values + if(parseInt(index) === (arraySize - 1)) { + _promises.forEach(function(promise) { + promise.then(function(result) { + // user requires how many values of the array to make the form input to be valid? + // If require "one", as soon as an array value changes is valid, the complete input becomes valid + // If require "all", as soon as an array value changes is invalid, the complete input becomes invalid + switch(_validArrayRequireHowMany) { + case "all" : + if(result.isFieldValid === false) { + result.formElmObj.translatePromise.then(function(translation) { + // if user is requesting to see only the last error message, we will use '=' instead of usually concatenating with '+=' + // then if validator rules has 'params' filled, then replace them inside the translation message (foo{0} {1}...), same syntax as String.format() in C# + if (_arrayErrorMessage.length > 0 && _globalOptions.displayOnlyLastErrorMsg) { + _arrayErrorMessage = '[' + result.value + '] :: ' + ((!!result.formElmObj.validator && !!result.formElmObj.validator.params) ? String.format(translation, result.formElmObj.validator.params) : translation); + } else { + _arrayErrorMessage += ' [' + result.value + '] :: ' + ((!!result.formElmObj.validator && !!result.formElmObj.validator.params) ? String.format(translation, result.formElmObj.validator.params) : translation); + } + commonObj.updateErrorMsg(_arrayErrorMessage, { isValid: false }); + commonObj.addToValidationSummary(result.formElmObj, _arrayErrorMessage); + }); + } + break; + case "one" : + default : + if(result.isFieldValid === true) { + ctrl.$setValidity('validation', true); + cancelValidation(); + } + } + }); + }); + } + } + } + + /** Definition of our blur event handler that will be used to attached on an element + * @param object event + */ + function blurHandler(event) { + // get the form element custom object and use it after + var formElmObj = commonObj.getFormElementByName(ctrl.$name); + var value = (typeof ctrl.$modelValue !== "undefined") ? ctrl.$modelValue : event.target.value; + + if (!!formElmObj && formElmObj.hasOwnProperty("isValidationCancelled")) { + // attempt to validate & run validation callback if user requested it + var validationPromise = attemptToValidate(value, 0); + if(!!_validationCallback) { + commonObj.runValidationCallbackOnPromise(validationPromise, _validationCallback); + } + }else { + ctrl.$setValidity('validation', true); + } + } + + /** Explode the input array and attempt to validate every single input values that comes out of it. + * Input array could be passed as 2 different types (array of string, array of objects) + * If we are dealing with an array of strings, we will consider the strings being the input value to validate + * But if instead it is an array of objects, we need to user to provide which object property name to use + * ex. : array of objects, var arrObj = [{ id: 1, label: 'tag1' }, { id: 2, label: 'tag2' }] + * --> we want the user to tell the directive that the input values are in the property name 'label' + * @param Array: input array + * @param string: array type + */ + function explodeArrayAndAttemptToValidate(inputArray, arrayType) { + var arraySize = inputArray.length; + + // array of strings, 1 for loop to get all input values + if(arrayType === "string") { + for (var key in inputArray) { + attemptToValidateArrayInput(inputArray[key], key, arraySize); + } + } + // array of objects, 2 for loops to get all input values via an object property name defined by the user + else if(arrayType === "object") { + for (var key in inputArray) { + if (inputArray.hasOwnProperty(key)) { + var obj = inputArray[key]; + for (var prop in obj) { + // check if there's a property on the object, compare it to what the user defined as the object property label + // then attempt to validate the array input value + if(obj.hasOwnProperty(prop)) { + if(!!_validationArrayObjprop && prop !== _validationArrayObjprop) { + continue; + } + attemptToValidateArrayInput(obj[prop], key, arraySize); + } + } + } + } + } + } + + /** Cancel the validation, unbind onBlur and remove from $validationSummary */ + function cancelAndUnbindValidation() { + // unbind everything and cancel the validation + cancelValidation(); + commonObj.removeFromValidationSummary(_elmName); + + // deregister the $watch from the _watchers array we kept it + var foundWatcher = commonObj.arrayFindObject(_watchers, 'elmName', ctrl.$name); + if(!!foundWatcher && typeof foundWatcher.watcherHandler === "function") { + var deregister = foundWatcher.watcherHandler(); // deregister the watch by calling his handler + _watchers.shift(); + } + } + + /** Cancel current validation test and blank any leftover error message */ + function cancelValidation() { + // get the form element custom object and use it after + var formElmObj = commonObj.getFormElementByName(ctrl.$name); + if(!!formElmObj) { + formElmObj.isValidationCancelled = true; + } + $timeout.cancel(_timer); + commonObj.updateErrorMsg(''); + ctrl.$setValidity('validation', true); + + // unbind onBlur handler (if found) so that it does not fail on a non-required element that is now dirty & empty + unbindBlurHandler(); + } + + /** watch the element for any value change, validate it once that happen + * @return new watcher + */ + function createWatch() { + return scope.$watch(function() { + var modelValue = ctrl.$modelValue; + if(isKeyTypedBadInput()) { + return { badInput: true }; + } + else if(!!_validationArrayObjprop && Array.isArray(modelValue) && modelValue.length === 0 && Object.keys(modelValue).length > 0) { + // when the modelValue is an Array but is length 0, this mean it's an Object disguise as an array + // since an Array of length 0 won't trigger a watch change, we need to return it back to an object + // for example Dropdown Multiselect when using selectionLimit of 1 will return [id: 1, label: 'John'], what we really want is the object { id: 1, label: 'John'} + // convert the object array to a real object that will go inside an array + var arr = [], obj = {}; + obj[_validationArrayObjprop] = modelValue[_validationArrayObjprop]; // convert [label: 'John'] to {label: 'John'} + arr.push(obj); // push to array: [{label: 'John'}] + return arr; + } + return modelValue; + }, function(newValue, oldValue) { + if(!!newValue && !!newValue.badInput) { + unbindBlurHandler(); + return invalidateBadInputField(); + } + // attempt to validate & run validation callback if user requested it + var validationPromise = attemptToValidate(newValue); + if(!!_validationCallback) { + commonObj.runValidationCallbackOnPromise(validationPromise, _validationCallback); + } + }, true); + } + + /** Invalidate the field that was tagged as bad input, cancel the timer validation, + * display an invalid key error and add it as well to the validation summary. + */ + function invalidateBadInputField() { + $timeout.cancel(_timer); + var formElmObj = commonObj.getFormElementByName(ctrl.$name); + commonObj.updateErrorMsg('INVALID_KEY_CHAR', { isValid: false, translate: true }); + commonObj.addToValidationSummary(formElmObj, 'INVALID_KEY_CHAR', true); + } + + /** Was the characters typed by the user bad input or not? + * @return bool + */ + function isKeyTypedBadInput() { + return (!!elm.prop('validity') && elm.prop('validity').badInput === true); + } + + /** Re-evaluate the element and revalidate it, also re-attach the onBlur event on the element */ + function revalidateAndAttachOnBlur() { + // Revalidate the input when enabled (without displaying the error) + var value = ctrl.$modelValue || ''; + if(!Array.isArray(value)) { + ctrl.$setValidity('validation', commonObj.validate(value, false)); + } + + // get the form element custom object and use it after + var formElmObj = commonObj.getFormElementByName(ctrl.$name); + if(!!formElmObj) { + formElmObj.isValidationCancelled = false; // make sure validation re-enabled as well + } + + // unbind previous handler (if any) not to have double handlers and then re-attach just 1 handler + unbindBlurHandler(); + elm.bind('blur', blurHandler); + } + + /** If found unbind the blur handler */ + function unbindBlurHandler() { + if(typeof blurHandler === "function") { + elm.unbind('blur', blurHandler); + } + } + + } // link() + }; // return; + }]); // directive +/** + * angular-validation-common (ghiscoding) + * https://github.com/ghiscoding/angular-validation + * + * @author: Ghislain B. + * @desc: angular-validation common functions used by both the Directive & Service + * + */ +angular + .module('ghiscoding.validation') + .factory('ValidationCommon', ['$rootScope', '$timeout', '$translate', 'ValidationRules', function ($rootScope, $timeout, $translate, ValidationRules) { + // global variables of our object (start with _var), these variables are shared between the Directive & Service + var _bFieldRequired = false; // by default we'll consider our field not required, if validation attribute calls it, then we'll start validating + var _INACTIVITY_LIMIT = 1000; // constant of maximum user inactivity time limit, this is the default cosntant but can be variable through typingLimit variable + var _formElements = []; // Array of all Form Elements, this is not a DOM Elements, these are custom objects defined as { fieldName, elm, attrs, ctrl, isValid, message } + var _globalOptions = { // Angular-Validation global options, could be define by scope.$validationOptions or by validationService.setGlobalOptions() + resetGlobalOptionsOnRouteChange: true // do we want to reset the Global Options on a route change? True by default + }; + var _remotePromises = []; // keep track of promises called and running when using the Remote validator + var _validationSummary = []; // Array Validation Error Summary + var _validateOnEmpty = false; // do we want to validate on empty field? False by default + + // watch on route change, then reset some global variables, so that we don't carry over other controller/view validations + $rootScope.$on("$routeChangeStart", function (event, next, current) { + resetGlobalOptions(_globalOptions.resetGlobalOptionsOnRouteChange); + }); + $rootScope.$on("$stateChangeStart", function (event, next, current) { + resetGlobalOptions(_globalOptions.resetGlobalOptionsOnRouteChange); + }); + + // service constructor + var validationCommon = function (scope, elm, attrs, ctrl) { + this.bFieldRequired = false; // by default we'll consider our field as not required, if validation attribute calls it, then we'll start validating + this.validators = []; + this.typingLimit = _INACTIVITY_LIMIT; + this.scope = scope; + this.elm = elm; + this.ctrl = ctrl; + this.validatorAttrs = attrs; + this.validateOnEmpty = false; // do we want to always validate, even when field isn't required? False by default + this.validRequireHowMany = "all"; + + if(!!scope && !!scope.$validationOptions) { + _globalOptions = scope.$validationOptions; // save the global options + } + + // user could pass his own scope, useful in a case of an isolate scope + if (!!scope && (!!_globalOptions.isolatedScope || !!_globalOptions.scope)) { + this.scope = _globalOptions.isolatedScope || _globalOptions.scope; // overwrite original scope (isolatedScope/scope are equivalent arguments) + _globalOptions = mergeObjects(scope.$validationOptions, _globalOptions); // reuse the validationOption from original scope + } + + // if the resetGlobalOptionsOnRouteChange doesn't exist, make sure to set it to True by default + if(typeof _globalOptions.resetGlobalOptionsOnRouteChange === "undefined") { + _globalOptions.resetGlobalOptionsOnRouteChange = true; + } + + // only the angular-validation Directive can possibly reach this condition with all properties filled + // on the other hand the angular-validation Service will `initialize()` function to initialize the same set of variables + if (!!this.elm && !!this.validatorAttrs && !!this.ctrl && !!this.scope) { + addToFormElementObjectList(this.elm, this.validatorAttrs, this.ctrl, this.scope); + this.defineValidation(); + } + }; + + // list of available published public functions of this object + validationCommon.prototype.addToValidationSummary = addToValidationSummary; // add an element to the $validationSummary + validationCommon.prototype.arrayFindObject = arrayFindObject; // search an object inside an array of objects + validationCommon.prototype.defineValidation = defineValidation; // define our validation object + validationCommon.prototype.getFormElementByName = getFormElementByName; // get the form element custom object by it's name + validationCommon.prototype.getFormElements = getFormElements; // get the array of form elements (custom objects) + validationCommon.prototype.getGlobalOptions = getGlobalOptions; // get the global options used by all validators (usually called by the validationService) + validationCommon.prototype.isFieldRequired = isFieldRequired; // return boolean knowing if the current field is required + validationCommon.prototype.initialize = initialize; // initialize current object with passed arguments + validationCommon.prototype.mergeObjects = mergeObjects; // merge 2 javascript objects, Overwrites obj1's values with obj2's (basically Object2 as higher priority over Object1) + validationCommon.prototype.parseBool = parseBool; // parse a boolean value, string or bool + validationCommon.prototype.removeFromValidationSummary = removeFromValidationSummary; // remove an element from the $validationSummary + validationCommon.prototype.removeFromFormElementObjectList = removeFromFormElementObjectList; // remove named items from formElements list + validationCommon.prototype.runValidationCallbackOnPromise = runValidationCallbackOnPromise; // run a validation callback method when the promise resolve + validationCommon.prototype.setDisplayOnlyLastErrorMsg = setDisplayOnlyLastErrorMsg; // setter on the behaviour of displaying only the last error message + validationCommon.prototype.setGlobalOptions = setGlobalOptions; // set global options used by all validators (usually called by the validationService) + validationCommon.prototype.updateErrorMsg = updateErrorMsg; // update on screen an error message below current form element + validationCommon.prototype.validate = validate; // validate current element + + // override some default String functions + if(window.Element && !Element.prototype.closest) { + Element.prototype.closest = elementPrototypeClosest; // Element Closest Polyfill for the browsers that don't support it (fingers point to IE) + } + String.prototype.trim = stringPrototypeTrim; // extend String object to have a trim function + String.prototype.format = stringPrototypeFormat; // extend String object to have a format function like C# + String.format = stringFormat; // extend String object to have a format function like C# + + + // return the service object + return validationCommon; + + //---- + // Public functions declaration + //---------------------------------- + + /** Add the error to the validation summary + * @param object self + * @param string message: error message + * @param bool need to translate: false by default + */ + function addToValidationSummary(self, message, needToTranslate) { + if (typeof self === "undefined" || self == null) { + return; + } + + // get the element name, whichever we find it + var elmName = (!!self.ctrl && !!self.ctrl.$name) + ? self.ctrl.$name + : (!!self.attrs && !!self.attrs.name) + ? self.attrs.name + : self.elm.attr('name'); + + var form = getElementParentForm(elmName, 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 !== '') { + if(!!needToTranslate) { + message = $translate.instant(message); + } + var friendlyName = (!!self.attrs && !!self.friendlyName) ? $translate.instant(self.friendlyName) : ''; + var errorObj = { field: elmName, friendlyName: friendlyName, 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) { + _validationSummary[index] = errorObj; + } else { + _validationSummary.push(errorObj); + } + } + + // save validation summary into scope root + self.scope.$validationSummary = _validationSummary; + + // and also save it inside the current scope form (if found) + if (!!form) { + // 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); + } + + // also save it inside the ControllerAs alias if it was passed in the global options + if (!!_globalOptions && !!_globalOptions.controllerAs) { + _globalOptions.controllerAs.$validationSummary = _validationSummary; + + // also save it inside controllerAs form (if found) + if (!!form && !!form.$name) { + var formName = form.$name.indexOf('.') >= 0 ? form.$name.split('.')[1] : form.$name; + var ctrlForm = (!!_globalOptions.controllerAs && !!_globalOptions.controllerAs[formName]) + ? _globalOptions.controllerAs[formName] + : ((typeof self.elm.controller() !== "undefined") ? self.elm.controller()[formName] : null); + + if(!!ctrlForm) { + ctrlForm.$validationSummary = arrayFindObjects(_validationSummary, 'formName', form.$name); + } + } + } + + return _validationSummary; + } + + /** Define our validation object + * @return object self + */ + function defineValidation() { + var self = this; + var customUserRegEx = {}; + self.validators = []; // reset the global validators + + // analyze the possible element attributes + self = analyzeElementAttributes(self); + + // get the rules(or validation), inside directive it's named (validation), inside service(rules) + var rules = self.validatorAttrs.rules || self.validatorAttrs.validation; + + // We first need to see if the validation holds a custom user regex, if it does then deal with it first + // So why deal with it separately? Because a Regex might hold pipe '|' and so we don't want to mix it with our regular validation pipe + if(rules.indexOf("pattern=/") >= 0) { + var matches = rules.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/); + if (!matches || matches.length < 3) { + throw 'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.'; + } + var pattern = matches[1]; + var altMsg = (!!matches[2]) ? matches[2].replace(/\|(.*)/, '') : ''; + + // convert the string into a real RegExp pattern + var match = pattern.match(new RegExp('^/(.*?)/([gimy]*)$')); + var regex = new RegExp(match[1], match[2]); + + customUserRegEx = { + altMsg: altMsg, + message: altMsg.replace(/:alt=/, ''), + pattern: regex + }; + + // rewrite the rules so that it doesn't contain any regular expression + // we simply remove the pattern so that it won't break the Angular-Validation since it also use the pipe | + rules = rules.replace('pattern=' + pattern, 'pattern'); + } + // DEPRECATED, in prior version of 1.3.34 and less, the way of writing a regular expression was through regex:/.../:regex + // this is no longer supported but is still part of the code so that it won't break for anyone using previous way of validating + // Return string will have the complete regex pattern removed but we will keep ':regex' so that we can still loop over it + else if (rules.indexOf("regex:") >= 0) { + var matches = rules.match("regex:(.*?):regex"); + if (matches.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 regAttrs = matches[1].split(':='); + customUserRegEx = { + message: regAttrs[0], + pattern: regAttrs[1] + }; + + // rewrite the rules so that it doesn't contain the regex: ... :regex ending + // we simply remove it so that it won't break if there's a pipe | inside the actual regex + rules = rules.replace(matches[0], 'regex:'); + } + + // at this point it's safe to split with pipe (since regex was previously stripped out) + var validations = rules.split('|'); + + if (validations) { + self.bFieldRequired = (rules.indexOf("required") >= 0); + + // loop through all validators of the element + for (var i = 0, ln = validations.length; i < ln; i++) { + // check if user provided an alternate text to his validator (validator:alt=Alternate Text) + var posAltText = validations[i].indexOf("alt="); + var hasAltText = posAltText >= 0; + var params = []; + + // alternate text might have the character ":" inside it, so we need to compensate + // since altText is always at the end, we can before the altText and add back this untouched altText to our params array + if(hasAltText) { + params = validations[i].substring(0,posAltText-1).split(':'); // split before altText, so we won't touch it + params.push(validations[i].substring(posAltText)); // add back the altText to our split params array + }else { + // params split will be:: [0]=rule, [1]=ruleExtraParams OR altText, [2] altText + params = validations[i].split(':'); + } + + self.validators[i] = ValidationRules.getElementValidators({ + altText: hasAltText === true ? (params.length === 2 ? params[1] : params[2]) : '', + customRegEx: customUserRegEx, + rule: params[0], + ruleParams: (hasAltText && params.length === 2) ? null : params[1] + }); + } + } + return self; + } // defineValidation() + + /** Return a Form element object by it's name + * @param string element input name + * @return array object elements + */ + function getFormElementByName(elmName) { + return arrayFindObject(_formElements, 'fieldName', elmName); + } + + /** Return all Form elements + * @param string form name + * @return array object elements + */ + function getFormElements(formName) { + if(!!formName) { + return arrayFindObjects(_formElements, 'formName', formName); + } + return _formElements; + } + + /** Get global options used by all validators + * @return object global options + */ + function getGlobalOptions() { + return _globalOptions; + } + + /** Initialize the common object + * @param object scope + * @param object elm + * @param object attrs + * @param object ctrl + */ + function initialize(scope, elm, attrs, ctrl) { + this.scope = scope; + this.elm = elm; + this.ctrl = ctrl; + this.validatorAttrs = attrs; + + addToFormElementObjectList(elm, attrs, ctrl, scope); + this.defineValidation(); + } + + /** @return isFieldRequired */ + function isFieldRequired() { + var self = this; + return self.bFieldRequired; + } + + /** + * Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1 + * When both object have the same property, the Object2 will higher priority over Object1 (basically that property will be overwritten inside Object1) + * @param obj1 + * @param obj2 + * @return obj3 a new object based on obj1 and obj2 + */ + function mergeObjects(obj1, obj2) { + var obj3 = {}; + for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; } + for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; } + + return obj3; + } + + /** Remove objects from FormElement list. + * @param element input name to remove + */ + function removeFromFormElementObjectList(elmName) { + var index = arrayFindObjectIndex(_formElements, 'fieldName', elmName); // find index of object in our array + if (index >= 0) { + _formElements.splice(index, 1); + } + } + + /** Remove an element from the $validationSummary array + * @param string elmName: element name + * @param object validationSummary + */ + function removeFromValidationSummary(elmName, validationSummaryObj) { + var self = this; + var form = getElementParentForm(elmName, self); // find the parent form (only found if it has a name) + var vsObj = validationSummaryObj || _validationSummary; + + var index = arrayFindObjectIndex(vsObj, 'field', elmName); // find index of object in our array + // if message is empty, remove it from the validation summary object + if (index >= 0) { + vsObj.splice(index, 1); + } + // also remove from 'local' validationSummary + index = arrayFindObjectIndex(_validationSummary, 'field', elmName); // find index of object in our array + if (index >= 0) { + _validationSummary.splice(index, 1); + } + + self.scope.$validationSummary = _validationSummary; + + // overwrite the scope form (if found) + if (!!form) { + // 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); + } + + // overwrite the ControllerAs alias if it was passed in the global options + if (!!_globalOptions && !!_globalOptions.controllerAs) { + _globalOptions.controllerAs.$validationSummary = _validationSummary; + + // also overwrite it inside controllerAs form (if found) + if (!!form) { + var formName = form.$name.indexOf('.') >= 0 ? form.$name.split('.')[1] : form.$name; + if(!!_globalOptions.controllerAs[formName]) { + _globalOptions.controllerAs[formName].$validationSummary = arrayFindObjects(_validationSummary, 'formName', form.$name); + } + } + } + + + return _validationSummary; + } + + /** Evaluate a function name passed as string and run it from the scope. + * The function name could be passed with/without brackets "()", in any case we will run the function + * @param object self object + * @param string function passed as a string + * @param mixed result + */ + function runEvalScopeFunction(self, fnString) { + var result; + + // Find if our function has the brackets "()" + // if yes then run it through $eval else find it in the scope and then run it + if(/\({1}.*\){1}/gi.test(fnString)) { + result = self.scope.$eval(fnString); + }else { + var fct = objectFindById(self.scope, fnString, '.'); + if(typeof fct === "function") { + result = fct(); + } + } + return result; + } + + /** Run a validation callback function once the promise return + * @param object validation promise + * @param string callback function name (could be with/without the brackets () ) + */ + function runValidationCallbackOnPromise(promise, callbackFct) { + var self = this; + + if(typeof promise.then === "function") { + promise.then(function() { + runEvalScopeFunction(self, callbackFct); + }); + } + } + + /** Setter on the behaviour of displaying only the last error message of each element. + * By default this is false, so the behavior is to display all error messages of each element. + * @param boolean value + */ + function setDisplayOnlyLastErrorMsg(boolValue) { + _globalOptions.displayOnlyLastErrorMsg = boolValue; + } + + /** Set and initialize global options used by all validators + * @param object attrs: global options + * @return object self + */ + function setGlobalOptions(options) { + var self = this; + + // merge both attributes but 2nd object (attrs) as higher priority, so that for example debounce property inside `attrs` as higher priority over `validatorAttrs` + // so the position inside the mergeObject call is very important + _globalOptions = mergeObjects(_globalOptions, options); // save in global + + return self; + } + + /** in general we will display error message at the next element after our input as + * but in some cases user might want to define which DOM id to display error (as validation attribute) + * @param string message: error message to display + * @param object arguments that could be passed to the function + */ + function updateErrorMsg(message, attrs) { + var self = this; + + // attrs.obj if set, should be a commonObj, and can be self. + // In addition we need to set validatorAttrs, as they are defined as attrs on obj. + if (!!attrs && attrs.obj) { + self = attrs.obj; + self.validatorAttrs = attrs.obj.attrs; + } + + // element name could be defined in the `attrs` or in the self object + var elm = (!!attrs && attrs.elm) ? attrs.elm : self.elm; + var elmName = (!!elm && elm.attr('name')) ? elm.attr('name') : null; + + // Make sure that element has a name="" attribute else it will not work + if (typeof elmName === "undefined" || elmName === null) { + var ngModelName = (!!elm) ? elm.attr('ng-model') : 'unknown'; + throw 'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="' + ngModelName + '"'; + } + + // user might have passed a message to be translated + var errorMsg = (!!attrs && !!attrs.translate) ? $translate.instant(message) : message; + errorMsg = errorMsg.trim(); + + // get the name attribute of current element, make sure to strip dirty characters, for example remove a , we need to strip the "[]" + // also replace any possible '.' inside the input name by '-' + var elmInputName = elmName.replace(/[|&;$%@"<>()+,\[\]\{\}]/g, '').replace(/\./g, '-'); + var errorElm = null; + + // find the element which we'll display the error message, this element might be defined by the user with 'validationErrorTo' + if (!!self.validatorAttrs && self.validatorAttrs.hasOwnProperty('validationErrorTo')) { + // validationErrorTo can be used in 3 different ways: with '.' (element error className) or with/without '#' (element error id) + var firstChar = self.validatorAttrs.validationErrorTo.charAt(0); + var selector = (firstChar === '.' || firstChar === '#') ? self.validatorAttrs.validationErrorTo : '#' + self.validatorAttrs.validationErrorTo; + errorElm = angular.element(document.querySelector(selector)); + } + // errorElm can be empty due to: + // 1. validationErrorTo has not been set + // 2. validationErrorTo has been mistyped, and if mistyped, use regular functionality + if (!errorElm || errorElm.length === 0) { + // most common way, let's try to find our + errorElm = angular.element(document.querySelector('.validation-' + elmInputName)); + } + + // form might have already been submitted + var isSubmitted = (!!attrs && attrs.isSubmitted) ? attrs.isSubmitted : false; + + // invalid & isDirty, display the error message... if not exist then create it, else udpate the text + if (!_globalOptions.hideErrorUnderInputs && !!attrs && !attrs.isValid && (isSubmitted || self.ctrl.$dirty || self.ctrl.$touched || self.ctrl.revalidateCalled)) { + (errorElm.length > 0) ? errorElm.html(errorMsg) : elm.after('
' + errorMsg + '
'); + self.ctrl.isErrorMessageVisible = true; + } else { + errorElm.html(''); // element is pristine or no validation applied, error message has to be blank + self.ctrl.isErrorMessageVisible = undefined; + } + } + + /** Validate function, from the input value it will go through all validators (separated by pipe) + * that were passed to the input element and will validate it. If field is invalid it will update + * the error text of the span/div element dedicated for that error display. + * @param string value: value of the input field + * @param bool showError: do we want to show the error or hide it (false is useful for adding error to $validationSummary without displaying it on screen) + * @return bool isFieldValid + */ + function validate(strValue, showError) { + var self = this; + var isConditionValid = true; + var isFieldValid = true; + var nbValid = 0; + var validator; + var validatedObject = {}; + + // make an object to hold the message so that we can reuse the object by reference + // in some of the validation check (for example "matching" and "remote") + var validationElmObj = { + message: '' + } + + // to make proper validation, our element value cannot be an undefined variable (we will at minimum make it an empty string) + // For example, in some particular cases "undefined" returns always True on regex.test() which is incorrect especially on max_len:x + if (typeof strValue === "undefined") { + strValue = ''; + } + + // get some common variables + var elmName = (!!self.ctrl && !!self.ctrl.$name) + ? self.ctrl.$name + : (!!self.attrs && !!self.attrs.name) + ? self.attrs.name + : self.elm.attr('name'); + + var formElmObj = getFormElementByName(elmName); + var rules = self.validatorAttrs.rules || self.validatorAttrs.validation; + + // loop through all validators (could be multiple) + for (var j = 0, jln = self.validators.length; j < jln; j++) { + validator = self.validators[j]; + + // When AutoDetect it will auto-detect the type and rewrite the conditions or regex pattern, depending on type found + if (validator.type === "autoDetect") { + validator = validatorAutoDetectType(validator, strValue); + } + + // get the disabled & ngDisabled attributes if found + var elmAttrDisabled = self.elm.prop("disabled"); + var elmAttrNgDisabled = (!!self.attrs) ? self.attrs.ngDisabled : self.validatorAttrs.ngDisabled; + + var isDisabled = (elmAttrDisabled === "") + ? true + : (typeof elmAttrDisabled === "boolean") + ? elmAttrDisabled + : (typeof elmAttrDisabled !== "undefined") ? self.scope.$eval(elmAttrDisabled) : false; + + var isNgDisabled = (elmAttrNgDisabled === "") + ? true + : (typeof elmAttrNgDisabled === "boolean") + ? elmAttrNgDisabled + : (typeof elmAttrNgDisabled !== "undefined") ? self.scope.$eval(elmAttrNgDisabled) : false; + + // now that we have a Validator type, we can now validate our value + // there is multiple type that can influence how the value will be validated + switch(validator.type) { + case "conditionalDate": + isConditionValid = validateConditionalDate(strValue, validator, rules); + break; + case "conditionalNumber": + isConditionValid = validateConditionalNumber(strValue, validator); + break; + case "javascript": + isConditionValid = validateCustomJavascript(strValue, validator, self, formElmObj, showError, validationElmObj); + break; + case "matching": + isConditionValid = validateMatching(strValue, validator, self, validationElmObj); + break; + case "remote": + isConditionValid = validateRemote(strValue, validator, self, formElmObj, showError, validationElmObj); + break; + default: + isConditionValid = validateWithRegex(strValue, validator, rules, self); + break; + } + + // not required and not filled is always valid & 'disabled', 'ng-disabled' elements should always be valid + if ((!self.bFieldRequired && !strValue && !_validateOnEmpty) || (isDisabled || isNgDisabled)) { + isConditionValid = true; + } + + if (!isConditionValid) { + isFieldValid = false; + + // run $translate promise, use closures to keep access to all necessary variables + (function (formElmObj, isConditionValid, validator) { + var msgToTranslate = validator.message; + var errorMessageSeparator = _globalOptions.errorMessageSeparator || ' '; + if (!!validator.altText && validator.altText.length > 0) { + msgToTranslate = validator.altText.replace("alt=", ""); + } + + var trsltPromise = $translate(msgToTranslate); + formElmObj.translatePromise = trsltPromise; + formElmObj.validator = validator; + + trsltPromise.then(function (translation) { + // if user is requesting to see only the last error message, we will use '=' instead of usually concatenating with '+=' + // then if validator rules has 'params' filled, then replace them inside the translation message (foo{0} {1}...), same syntax as String.format() in C# + if (validationElmObj.message.length > 0 && _globalOptions.displayOnlyLastErrorMsg) { + validationElmObj.message = errorMessageSeparator + ((!!validator && !!validator.params) ? String.format(translation, validator.params) : translation); + } else { + validationElmObj.message += errorMessageSeparator + ((!!validator && !!validator.params) ? String.format(translation, validator.params) : translation); + } + addToValidationAndDisplayError(self, formElmObj, validationElmObj.message, isFieldValid, showError); + }) + ["catch"](function (data) { + // error caught: + // alternate text might not need translation if the user sent his own custom message or is already translated + // so just send it directly into the validation summary. + if (!!validator.altText && validator.altText.length > 0) { + // if user is requesting to see only the last error message + if (validationElmObj.message.length > 0 && _globalOptions.displayOnlyLastErrorMsg) { + validationElmObj.message = errorMessageSeparator + msgToTranslate; + } else { + validationElmObj.message += errorMessageSeparator + msgToTranslate; + } + addToValidationAndDisplayError(self, formElmObj, validationElmObj.message, isFieldValid, showError); + } else { + throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.", data); + } + }); + })(formElmObj, isConditionValid, validator); + } // if(!isConditionValid) + + if(isConditionValid) { + nbValid++; + } + + // when user want the field to become valid as soon as we have 1 validator passing + if(self.validRequireHowMany == nbValid && !!isConditionValid) { + isFieldValid = true; + break; + } + } // for() loop + + // only log the invalid message in the $validationSummary + if (isConditionValid) { + addToValidationSummary(self, ''); + self.updateErrorMsg('', { isValid: isConditionValid }); + } + + if (!!formElmObj) { + formElmObj.isValid = isFieldValid; + if (isFieldValid) { + formElmObj.message = ''; + } + } + return isFieldValid; + } // validate() + + //---- + // Private functions declaration + //---------------------------------- + + /** Add to the Form Elements Array of Object List + * @param object elm + * @param object attrs + * @param object ctrl + * @param object scope + */ + function addToFormElementObjectList(elm, attrs, ctrl, scope) { + var elmName = (!!attrs.name) ? attrs.name : elm.attr('name'); + var form = getElementParentForm(elmName, { scope: scope }); // find the parent form (only found if it has a name) + var friendlyName = (!!attrs && !!attrs.friendlyName) ? $translate.instant(attrs.friendlyName) : ''; + var formElm = { fieldName: elmName, friendlyName: friendlyName, elm: elm, attrs: attrs, ctrl: ctrl, scope: scope, isValid: false, message: '', formName: (!!form) ? form.$name : null }; + var index = arrayFindObjectIndex(_formElements, 'fieldName', elm.attr('name')); // find index of object in our array + if (index >= 0) { + _formElements[index] = formElm; + } else { + _formElements.push(formElm); + } + return _formElements; + } + + /** Will add error to the validationSummary and also display the error message if requested + * @param object self + * @param object formElmObj + * @param string message: error message + * @param bool is field valid? + * @param bool showError + */ + function addToValidationAndDisplayError(self, formElmObj, message, isFieldValid, showError) { + // trim any white space + message = message.trim(); + + // if validation is cancelled, then erase error message + if(!!formElmObj && formElmObj.isValidationCancelled === true) { + message = ''; + } + + // log the invalid message in the $validationSummary + // that is if the preValidationSummary is set to True, non-existent or we simply want to display error) + if(!!_globalOptions.preValidateValidationSummary || typeof _globalOptions.preValidateValidationSummary === "undefined" || showError) { + addToValidationSummary(formElmObj, message); + } + + // change the Form element object boolean flag from the `formElements` variable, used in the `checkFormValidity()` + if (!!formElmObj) { + //formElmObj.message = message; + } + + // if user is pre-validating all form elements, display error right away + if (!!self.validatorAttrs.preValidateFormElements || !!_globalOptions.preValidateFormElements) { + // make the element as it was touched for CSS, only works in AngularJS 1.3+ + if (!!formElmObj && typeof self.ctrl.$setTouched === "function") { + formElmObj.ctrl.$setTouched(); + } + // only display errors on page load, when elements are not yet dirty + if (self.ctrl.$dirty === false) { + updateErrorMsg(message, { isSubmitted: true, isValid: isFieldValid, obj: formElmObj }); + } + } + + // error Display + if (showError && !!formElmObj && !formElmObj.isValid) { + self.updateErrorMsg(message, { isValid: isFieldValid, obj: formElmObj }); + } else if (!!formElmObj && formElmObj.isValid) { + addToValidationSummary(formElmObj, ''); + } + } + + /** Analyse the certain attributes that the element can have or could be passed by global options + * @param object self + * @return self + */ + function analyzeElementAttributes(self) { + // debounce (alias of typingLimit) timeout after user stop typing and validation comes in play + self.typingLimit = _INACTIVITY_LIMIT; + if (self.validatorAttrs.hasOwnProperty('debounce')) { + self.typingLimit = parseInt(self.validatorAttrs.debounce, 10); + } else if (self.validatorAttrs.hasOwnProperty('typingLimit')) { + self.typingLimit = parseInt(self.validatorAttrs.typingLimit, 10); + } else if (!!_globalOptions && _globalOptions.hasOwnProperty('debounce')) { + self.typingLimit = parseInt(_globalOptions.debounce, 10); + } + + // how many Validators it needs to pass for the field to become valid, "all" by default + self.validRequireHowMany = self.validatorAttrs.hasOwnProperty('validRequireHowMany') + ? self.validatorAttrs.validRequireHowMany + : _globalOptions.validRequireHowMany; + + // do we want to validate on empty field? Useful on `custom` and `remote` + _validateOnEmpty = self.validatorAttrs.hasOwnProperty('validateOnEmpty') + ? parseBool(self.validatorAttrs.validateOnEmpty) + : _globalOptions.validateOnEmpty; + + return self; + } + + /** Quick function to find an object inside an array by it's given field name and value, return the object found or null + * @param Array sourceArray + * @param string searchId: search property id + * @param string searchValue: value to search + * @return object found from source array or null + */ + function arrayFindObject(sourceArray, searchId, searchValue) { + if (!!sourceArray) { + for (var i = 0; i < sourceArray.length; i++) { + if (sourceArray[i][searchId] === searchValue) { + return sourceArray[i]; + } + } + } + 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 = []; + if (!!sourceArray) { + 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 + * @param string searchValue: value to search + * @return int index position found + */ + function arrayFindObjectIndex(sourceArray, searchId, searchValue) { + if (!!sourceArray) { + for (var i = 0; i < sourceArray.length; i++) { + if (sourceArray[i][searchId] === searchValue) { + return i; + } + } + } + + return -1; + } + + /** From a javascript plain form object, find its equivalent Angular object + * @param object formObj + * @param object self + * @return object angularParentForm or null + */ + function findAngularParentFormInScope(formObj, self) { + var formName = (!!formObj) ? formObj.getAttribute("name") : null; + + if (!!formObj && !!formName) { + parentForm = (!!_globalOptions && !!_globalOptions.controllerAs && formName.indexOf('.') >= 0) + ? objectFindById(self.scope, formName, '.') + : self.scope[formName]; + + if(!!parentForm) { + if (typeof parentForm.$name === "undefined") { + parentForm.$name = formName; // make sure it has a $name, since we use that variable later on + } + return parentForm; + } + } + + return null; + } + + /** Get the element's parent Angular form (if found) + * @param string: element input name + * @param object self + * @return object scope form + */ + function getElementParentForm(elmName, self) { + // get the parentForm directly by it's formName if it was passed in the global options + if(!!_globalOptions && !!_globalOptions.formName) { + var parentForm = document.querySelector('[name="'+_globalOptions.formName+'"]'); + if(!!parentForm) { + parentForm.$name = _globalOptions.formName; // make sure the parentForm as a $name for later usage + return parentForm; + } + } + + // from the element passed, get his parent form (this doesn't work with every type of element, for example it doesn't work with
or special angular element) + var forms = document.getElementsByName(elmName); + var parentForm = null; + + for (var i = 0; i < forms.length; i++) { + var form = forms[i].form; + var angularParentForm = findAngularParentFormInScope(form, self); + if(!!angularParentForm) { + return angularParentForm; + } + } + + // if we haven't found a form yet, then we have a special angular element, let's try with .closest + if(!form) { + var element = document.querySelector('[name="'+elmName+'"]'); + if(!!element) { + var form = element.closest("form"); + var angularParentForm = findAngularParentFormInScope(form, self); + if(!!angularParentForm) { + return angularParentForm; + } + } + } + + // falling here with a form name but without a form object found in the scope is often due to isolate scope + // we can hack it and define our own form inside this isolate scope, in that way we can still use something like: isolateScope.form1.$validationSummary + if (!!form) { + var formName = (!!form) ? form.getAttribute("name") : null; + if(!!formName) { + var obj = { $name: formName, specialNote: 'Created by Angular-Validation for Isolated Scope usage' }; + + if (!!_globalOptions && !!_globalOptions.controllerAs && formName.indexOf('.') >= 0) { + var formSplit = formName.split('.'); + return self.scope[formSplit[0]][formSplit[1]] = obj + } + return self.scope[formName] = obj; + } + } + return null; + } + + /** Check if the given argument is numeric + * @param mixed n + * @return bool + */ + function isNumeric(n) { + return !isNaN(parseFloat(n)) && isFinite(n); + } + + /** Find a property inside an object. + * If a delimiter is passed as argument, we will split the search ID before searching + * @param object: source object + * @param string: searchId + * @return mixed: property found + */ + function objectFindById(sourceObject, searchId, delimiter) { + var split = (!!delimiter) ? searchId.split(delimiter) : searchId; + + for (var k = 0, kln = split.length; k < kln; k++) { + if(!!sourceObject[split[k]]) { + sourceObject = sourceObject[split[k]]; + } + } + return sourceObject; + } + + /** Parse a boolean value, we also want to parse on string values + * @param string/int value + * @return bool + */ + function parseBool(value) { + if(typeof value === "boolean" || typeof value === "number") { + return (value === true || value === 1); + } + else if (typeof value === "string") { + value = value.replace(/^\s+|\s+$/g, "").toLowerCase(); + if (value === "true" || value === "1" || value === "false" || value === "0") + return (value === "true" || value === "1"); + } + return; // returns undefined + } + + /** Parse a date from a String and return it as a Date Object to be valid for all browsers following ECMA Specs + * Date type ISO (default), US, UK, Europe, etc... Other format could be added in the switch case + * @param String dateStr: date String + * @param String dateType: date type (ISO, US, etc...) + * @return object date + */ + function parseDate(dateStr, dateType) { + // variables declaration + var dateSubStr = '', dateSeparator = '-', dateSplit = [], timeSplit = [], year = '', month = '', day = ''; + + // Parse using the date type user selected, (separator could be dot, slash or dash) + switch (dateType.toUpperCase()) { + case 'EURO_LONG': + case 'EURO-LONG': // UK, Europe long format is: dd/mm/yyyy hh:mm:ss + dateSubStr = dateStr.substring(0, 10); + dateSeparator = dateStr.substring(2, 3); + dateSplit = splitDateString(dateSubStr, dateSeparator); + day = dateSplit[0]; + month = dateSplit[1]; + year = dateSplit[2]; + timeSplit = (dateStr.length > 8) ? dateStr.substring(9).split(':') : null; + break; + case 'UK': + case 'EURO': + case 'EURO_SHORT': + case 'EURO-SHORT': + case 'EUROPE': // UK, Europe format is: dd/mm/yy hh:mm:ss + dateSubStr = dateStr.substring(0, 8); + dateSeparator = dateStr.substring(2, 3); + dateSplit = splitDateString(dateSubStr, dateSeparator); + day = dateSplit[0]; + month = dateSplit[1]; + year = (parseInt(dateSplit[2]) < 50) ? ('20' + dateSplit[2]) : ('19' + dateSplit[2]); // below 50 we'll consider that as century 2000's, else in century 1900's + timeSplit = (dateStr.length > 8) ? dateStr.substring(9).split(':') : null; + break; + case 'US_LONG': + case 'US-LONG': // US long format is: mm/dd/yyyy hh:mm:ss + dateSubStr = dateStr.substring(0, 10); + dateSeparator = dateStr.substring(2, 3); + dateSplit = splitDateString(dateSubStr, dateSeparator); + month = dateSplit[0]; + day = dateSplit[1]; + year = dateSplit[2]; + timeSplit = (dateStr.length > 8) ? dateStr.substring(9).split(':') : null; + break; + case 'US': + case 'US_SHORT': + case 'US-SHORT': // US short format is: mm/dd/yy hh:mm:ss OR + dateSubStr = dateStr.substring(0, 8); + dateSeparator = dateStr.substring(2, 3); + dateSplit = splitDateString(dateSubStr, dateSeparator); + month = dateSplit[0]; + day = dateSplit[1]; + year = (parseInt(dateSplit[2]) < 50) ? ('20' + dateSplit[2]) : ('19' + dateSplit[2]); // below 50 we'll consider that as century 2000's, else in century 1900's + timeSplit = (dateStr.length > 8) ? dateStr.substring(9).split(':') : null; + break; + case 'ISO': + default: // ISO format is: yyyy-mm-dd hh:mm:ss (separator could be dot, slash or dash: ".", "/", "-") + dateSubStr = dateStr.substring(0, 10); + dateSeparator = dateStr.substring(4, 5); + dateSplit = splitDateString(dateSubStr, dateSeparator); + year = dateSplit[0]; + month = dateSplit[1]; + day = dateSplit[2]; + timeSplit = (dateStr.length > 10) ? dateStr.substring(11).split(':') : null; + break; + } + + // parse the time if it exist else put them at 0 + var hour = (!!timeSplit && timeSplit.length === 3) ? timeSplit[0] : 0; + var min = (!!timeSplit && timeSplit.length === 3) ? timeSplit[1] : 0; + var sec = (!!timeSplit && timeSplit.length === 3) ? timeSplit[2] : 0; + + // Construct a valid Date Object that follows the ECMA Specs + // Note that, in JavaScript, months run from 0 to 11, rather than 1 to 12! + return new Date(year, month - 1, day, hour, min, sec); + } + + /** Reset all the available Global Options of Angular-Validation + * @param bool do a Reset? + */ + function resetGlobalOptions(doReset) { + if (doReset) { + _globalOptions = { + displayOnlyLastErrorMsg: false, // reset the option of displaying only the last error message + errorMessageSeparator: ' ', // separator between each error messages (when multiple errors exist) + hideErrorUnderInputs: false, // reset the option of hiding error under element + preValidateFormElements: false, // reset the option of pre-validate all form elements, false by default + preValidateValidationSummary: true, // reset the option of pre-validate all form elements, false by default + isolatedScope: null, // reset used scope on route change + scope: null, // reset used scope on route change + validateOnEmpty: false, // reset the flag of Validate Always + validRequireHowMany: 'all', // how many Validators it needs to pass for the field to become valid, "all" by default + resetGlobalOptionsOnRouteChange: true + }; + _formElements = []; // array containing all form elements, valid or invalid + _validationSummary = []; // array containing the list of invalid fields inside a validationSummary + } + } + + /** From a date substring split it by a given separator and return a split array + * @param string dateSubStr + * @param string dateSeparator + * @return array date splitted + */ + function splitDateString(dateSubStr, dateSeparator) { + var dateSplit = []; + + switch (dateSeparator) { + case '/': + dateSplit = dateSubStr.split('/'); break; + case '.': + dateSplit = dateSubStr.split('.'); break; + case '-': + default: + dateSplit = dateSubStr.split('-'); break; + } + + return dateSplit; + } + + /** Test values with condition, I have created a switch case for all possible conditions. + * @param string condition: condition to filter with + * @param any value1: 1st value to compare, the type could be anything (number, String or even Date) + * @param any value2: 2nd value to compare, the type could be anything (number, String or even Date) + * @return boolean: a boolean result of the tested condition (true/false) + */ + function testCondition(condition, value1, value2) { + var result = false; + + switch (condition) { + case '<': result = (value1 < value2); break; + case '<=': result = (value1 <= value2); break; + case '>': result = (value1 > value2); break; + case '>=': result = (value1 >= value2); break; + case '!=': + case '<>': result = (value1 != value2); break; + case '!==': result = (value1 !== value2); break; + case '=': + case '==': result = (value1 == value2); break; + case '===': result = (value1 === value2); break; + default: result = false; break; + } + return result; + } + + /** Element Closest Polyfill for the browsers that don't support it (fingers point to IE) + * https://developer.mozilla.org/en-US/docs/Web/API/Element/closest + */ + function elementPrototypeClosest() { + Element.prototype.closest = + function(s) { + var matches = (this.document || this.ownerDocument).querySelectorAll(s), + i, + el = this; + + do { + i = matches.length; + while (--i >= 0 && matches.item(i) !== el) {}; + } while ((i < 0) && (el = el.parentElement)); + return el; + }; + } + + /** Override javascript trim() function so that it works accross all browser platforms */ + function stringPrototypeTrim() { + return this.replace(/^\s+|\s+$/g, ''); + } + + /** Override javascript format() function to be the same as the effect as the C# String.Format + * Input: "Some {0} are showing {1}".format("inputs", "invalid"); + * Output: "Some inputs are showing invalid" + * @param string + * @param replacements + */ + function stringPrototypeFormat() { + var args = (Array.isArray(arguments[0])) ? arguments[0] : arguments; + return this.replace(/{(\d+)}/g, function (match, number) { + return (typeof args[number] !== "undefined") ? args[number] : match; + }); + } + + /** Override javascript String.format() function to be the same as the effect as the C# String.Format + * Input: String.format("Some {0} are showing {1}", "inputs", "invalid"); + * Output: "Some inputs are showing invalid" + * @param string + * @param replacements + */ + function stringFormat(format) { + var args = (Array.isArray(arguments[1])) ? arguments[1] : Array.prototype.slice.call(arguments, 1); + + return format.replace(/{(\d+)}/g, function (match, number) { + return (typeof args[number] !== "undefined") ? args[number] : match; + }); + } + + /** Validating a Conditional Date, user want to valid if his date is smaller/higher compare to another. + * @param string value + * @param object validator + * @param object rules + * @return bool isValid + */ + function validateConditionalDate(strValue, validator, rules) { + var isValid = true; + var isWellFormed = isValid = false; + + // 1- make sure Date is well formed (if it's already a Date object then it's already good, else check that with Regex) + if((strValue instanceof Date)) { + isWellFormed = true; + }else { + // run the Regex test through each iteration, if required (\S+) and is null then it's invalid automatically + var regex = new RegExp(validator.pattern, validator.patternFlag); + isWellFormed = ((!validator.pattern || validator.pattern.toString() === "/\\S+/" || (!!rules && validator.pattern === "required")) && strValue === null) ? false : regex.test(strValue); + } + + // 2- date is well formed, then go ahead with conditional date check + if (isWellFormed) { + // For Date comparison, we will need to construct a Date Object that follows the ECMA so then it could work in all browser + // Then convert to timestamp & finally we can compare both dates for filtering + var dateType = validator.dateType; // date type (ISO, EURO, US-SHORT, US-LONG) + var timestampValue = (strValue instanceof Date) ? strValue : parseDate(strValue, dateType).getTime(); // our input value parsed into a timestamp + + // if 2 params, then it's a between condition + if (validator.params.length == 2) { + // this is typically a "between" condition, a range of number >= and <= + var timestampParam0 = parseDate(validator.params[0], dateType).getTime(); + var timestampParam1 = parseDate(validator.params[1], dateType).getTime(); + var isValid1 = testCondition(validator.condition[0], timestampValue, timestampParam0); + var isValid2 = testCondition(validator.condition[1], timestampValue, timestampParam1); + isValid = (isValid1 && isValid2); + } else { + // else, 1 param is a simple conditional date check + var timestampParam = parseDate(validator.params[0], dateType).getTime(); + isValid = testCondition(validator.condition, timestampValue, timestampParam); + } + } + + return isValid; + } + + /** Validating a Conditional Number, user want to valid if his number is smaller/higher compare to another. + * @param string value + * @param object validator + * @return bool isValid + */ + function validateConditionalNumber(strValue, validator) { + var isValid = true; + + // if 2 params, then it's a between condition + if (validator.params.length == 2) { + // this is typically a "between" condition, a range of number >= and <= + var isValid1 = testCondition(validator.condition[0], parseFloat(strValue), parseFloat(validator.params[0])); + var isValid2 = testCondition(validator.condition[1], parseFloat(strValue), parseFloat(validator.params[1])); + isValid = (isValid1 && isValid2); + } else { + // else, 1 param is a simple conditional number check + isValid = testCondition(validator.condition, parseFloat(strValue), parseFloat(validator.params[0])); + } + + return isValid; + } + + /** Make a Custom Javascript Validation, this should return a boolean or an object as { isValid: bool, message: msg } + * The argument of `validationElmObj` is mainly there only because it's passed by reference (pointer reference) and + * by the time the $translate promise is done with the translation then the promise in our function will have the latest error message. + * @param string value + * @param object validator + * @param object self + * @param object formElmObj + * @param bool showError + * @param object element validation object (passed by reference) + * @return bool isValid + */ + function validateCustomJavascript(strValue, validator, self, formElmObj, showError, validationElmObj) { + var isValid = true; + var missingErrorMsg = "Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }" + var invalidResultErrorMsg = 'Custom Javascript Validation requires a declared function (in your Controller), please review your code.'; + + if (!!strValue || !!_validateOnEmpty) { + var fct = null; + var fname = validator.params[0]; + var result = runEvalScopeFunction(self, fname); + + // analyze the result, could be a boolean or object type, anything else will throw an error + if (typeof result === "boolean") { + isValid = (!!result); + } + else if (typeof result === "object") { + isValid = (!!result.isValid); + } + else { + throw invalidResultErrorMsg; + } + + if (isValid === false) { + formElmObj.isValid = false; + + // is field is invalid and we have an error message given, then add it to validationSummary and display error + // use of $timeout to make sure we are always at the end of the $digest + // if user passed the error message from inside the custom js function, $translate would come and overwrite this error message and so being sure that we are at the end of the $digest removes this issue. + $timeout(function() { + var errorMsg = validationElmObj.message + ' '; + if(!!result.message) { + errorMsg += result.message || validator.altText; + } + if(errorMsg === ' ' && !!validator.altText) { + errorMsg += validator.altText; + } + if(errorMsg === ' ') { + throw missingErrorMsg; + } + + addToValidationAndDisplayError(self, formElmObj, errorMsg, false, showError); + }); + } + else if (isValid === true) { + // if field is valid from the remote check (isValid) and from the other validators check (isFieldValid) + // clear up the error message and make the field directly as Valid with $setValidity since remote check arrive after all other validators check + formElmObj.isValid = true; + addToValidationAndDisplayError(self, formElmObj, '', true, showError); + } + + if(typeof result === "undefined") { + throw invalidResultErrorMsg; + } + } + + return isValid; + } + + /** Validating a match input checking, it could a check to be the same as another input or even being different. + * The argument of `validationElmObj` is mainly there only because it's passed by reference (pointer reference) and + * by the time the $translate promise is done with the translation then the promise in our function will have the latest error message. + * @param string value + * @param object validator + * @param object self + * @param object element validation object (passed by reference) + * @return bool isValid + */ + function validateMatching(strValue, validator, self, validationElmObj) { + var isValid = true; + + // get the element 'value' ngModel to compare to (passed as params[0], via an $eval('ng-model="modelToCompareName"') + // for code purpose we'll name the other parent element "parent..." + // and we will name the current element "matching..." + var parentNgModel = validator.params[0]; + var parentNgModelVal = self.scope.$eval(parentNgModel); + var otherElm = angular.element(document.querySelector('[name="'+parentNgModel+'"]')); + var matchingValidator = validator; // keep reference of matching confirmation validator + var matchingCtrl = self.ctrl; // keep reference of matching confirmation controller + var formElmMatchingObj = getFormElementByName(self.ctrl.$name); + + isValid = (testCondition(validator.condition, strValue, parentNgModelVal) && !!strValue); + + // if element to compare against has a friendlyName or if matching 2nd argument was passed, we will use that as a new friendlyName + // ex.: :: we would use the friendlyName of 'Password1' not input1 + // or :: we would use Password2 not input1 + if(!!otherElm && !!otherElm.attr('friendly-name')) { + validator.params[1] = otherElm.attr('friendly-name'); + } + else if(validator.params.length > 1) { + validator.params[1] = validator.params[1]; + } + + // Watch for the parent ngModel, if it change we need to re-validate the child (confirmation) + self.scope.$watch(parentNgModel, function(newVal, oldVal) { + var isWatchValid = testCondition(matchingValidator.condition, matchingCtrl.$viewValue, newVal); + + // only inspect on a parent input value change + if(newVal !== oldVal) { + // If Valid then erase error message ELSE make matching field Invalid + if(isWatchValid) { + addToValidationAndDisplayError(self, formElmMatchingObj, '', true, true); + }else { + formElmMatchingObj.isValid = false; + var msgToTranslate = matchingValidator.message; + if (!!matchingValidator.altText && matchingValidator.altText.length > 0) { + msgToTranslate = matchingValidator.altText.replace("alt=", ""); + } + $translate(msgToTranslate).then(function (translation) { + var errorMessageSeparator = _globalOptions.errorMessageSeparator || ' '; + validationElmObj.message = errorMessageSeparator + ((!!matchingValidator && !!matchingValidator.params) ? String.format(translation, matchingValidator.params) : translation); + addToValidationAndDisplayError(self, formElmMatchingObj, validationElmObj.message, isWatchValid, true); + }); + } + matchingCtrl.$setValidity('validation', isWatchValid); // change the validity of the matching input + } + }, true); // .$watch() + + return isValid; + } + + /** Make an AJAX Remote Validation with a backend server, this should return a promise with the result as a boolean or a { isValid: bool, message: msg } + * The argument of `validationElmObj` is mainly there only because it's passed by reference (pointer reference) and + * by the time the $translate promise is done with the translation then the promise in our function will have the latest error message. + * @param string value + * @param object validator + * @param object self + * @param object formElmObj + * @param bool showError + * @param object element validation object (passed by reference) + * @return bool isValid + */ + function validateRemote(strValue, validator, self, formElmObj, showError, validationElmObj) { + var isValid = true; + var missingErrorMsg = "Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }" + var invalidResultErrorMsg = 'Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.'; + + if ((!!strValue && !!showError) || !!_validateOnEmpty) { + self.ctrl.$processing = true; // $processing can be use in the DOM to display a remote processing message to the user + + var fct = null; + var fname = validator.params[0]; + var promise = runEvalScopeFunction(self, fname); + + // if we already have previous promises running, we might want to abort them (if user specified an abort function) + if (_remotePromises.length > 1) { + while (_remotePromises.length > 0) { + var previousPromise = _remotePromises.pop(); + if (!!previousPromise && typeof previousPromise.abort === "function") { + previousPromise.abort(); // run the abort if user declared it + } + } + } + _remotePromises.push(promise); // always add to beginning of array list of promises + + if (!!promise && typeof promise.then === "function") { + self.ctrl.$setValidity('remote', false); // make the field invalid before processing it + + // process the promise + (function (altText) { + promise.then(function (result) { + result = result.data || result; + _remotePromises.pop(); // remove the last promise from array list of promises + self.ctrl.$processing = false; // finished resolving, no more pending + + var errorMsg = validationElmObj.message + ' '; + + // analyze the result, could be a boolean or object type, anything else will throw an error + if (typeof result === "boolean") { + isValid = (!!result); + } + else if (typeof result === "object") { + isValid = (!!result.isValid); + } + else { + throw invalidResultErrorMsg; + } + + if (isValid === false) { + formElmObj.isValid = false; + errorMsg += result.message || altText; + if(errorMsg === ' ') { + throw missingErrorMsg; + } + + // is field is invalid and we have an error message given, then add it to validationSummary and display error + addToValidationAndDisplayError(self, formElmObj, errorMsg, false, showError); + } + else if (isValid === true) { + // if field is valid from the remote check (isValid) and from the other validators check (isFieldValid) + // clear up the error message and make the field directly as Valid with $setValidity since remote check arrive after all other validators check + formElmObj.isValid = true; + self.ctrl.$setValidity('remote', true); + addToValidationAndDisplayError(self, formElmObj, '', true, showError); + } + }); + })(validator.altText); + } else { + throw invalidResultErrorMsg; + } + } + + return isValid; + } + + /** Validating through a regular regex pattern checking + * @param string value + * @param object validator + * @param object rules + * @param object self + * @return bool isValid + */ + function validateWithRegex(strValue, validator, rules, self) { + var isValid = true; + + // get the ngDisabled attribute if found + var elmAttrNgDisabled = (!!self.attrs) ? self.attrs.ngDisabled : self.validatorAttrs.ngDisabled; + var elmAttrDisabled = self.elm.prop("disabled"); + + var isDisabled = (elmAttrDisabled === "") + ? true + : (typeof elmAttrDisabled === "boolean") + ? elmAttrDisabled + : (typeof elmAttrDisabled !== "undefined") ? self.scope.$eval(elmAttrDisabled) : false; + + var isNgDisabled = (elmAttrNgDisabled === "") + ? true + : (typeof elmAttrNgDisabled === "boolean") + ? elmAttrNgDisabled + : (typeof elmAttrNgDisabled !== "undefined") ? self.scope.$eval(elmAttrNgDisabled) : false; + + // a 'disabled' element should always be valid, there is no need to validate it + if (isDisabled || isNgDisabled) { + isValid = true; + } else { + // before running Regex test, we'll make sure that an input of type="number" doesn't hold invalid keyboard chars, if true skip Regex + if (typeof strValue === "string" && strValue === "" && !!self.elm.prop('type') && self.elm.prop('type').toUpperCase() === "NUMBER") { + isValid = false; + } else { + // run the Regex test through each iteration, if required (\S+) and is null then it's invalid automatically + var regex = new RegExp(validator.pattern, validator.patternFlag); + isValid = ((!validator.pattern || validator.pattern.toString() === "/\\S+/" || (!!rules && validator.pattern === "required")) && strValue === null) ? false : regex.test(strValue); + } + } + + return isValid; + } + + /** AutoDetect type is a special case and will detect if the given value is of type numeric or not. + * then it will rewrite the conditions or regex pattern, depending on type found + * @param object validator + * @return object rewritten validator + */ + function validatorAutoDetectType(validator, strValue) { + if (isNumeric(strValue)) { + return { + condition: validator.conditionNum, + message: validator.messageNum, + params: validator.params, + type: "conditionalNumber" + }; + }else { + return { + pattern: validator.patternLength, + message: validator.messageLength, + params: validator.params, + type: "regex" + }; + } + + return {}; + } + + }]); // validationCommon service + +/** + * angular-validation-rules (ghiscoding) + * https://github.com/ghiscoding/angular-validation + * + * @author: Ghislain B. + * @desc: angular-validation rules definition + * Each rule objects must have 3 properties {pattern, message, type} + * and in some cases you could also define a 4th properties {params} to pass extras, for example: max_len will know his maximum length by this extra {params} + * Rule.type can be {autoDetect, conditionalDate, conditionalNumber, matching, regex} + * + * WARNING: Rule patterns are defined as String type so don't forget to escape your characters: \\ + */ +angular + .module('ghiscoding.validation') + .factory('ValidationRules', [function () { + // return the service object + var service = { + getElementValidators: getElementValidators + }; + return service; + + //---- + // Functions declaration + //---------------------------------- + + /** Get the element active validators and store it inside an array which will be returned + * @param object args: all attributes + */ + function getElementValidators(args) { + // grab all passed attributes + var alternateText = (typeof args.altText !== "undefined") ? args.altText.replace("alt=", "") : null; + var customUserRegEx = (args.hasOwnProperty('customRegEx')) ? args.customRegEx : null; + var rule = (args.hasOwnProperty('rule')) ? args.rule : null; + var ruleParams = (args.hasOwnProperty('ruleParams')) ? args.ruleParams : null; + + // validators on the current DOM element, an element can have 1+ validators + var validator = {}; + + switch(rule) { + case "accepted": + validator = { + pattern: /^(yes|on|1|true)$/i, + message: "INVALID_ACCEPTED", + type: "regex" + }; + break; + case "alpha" : + validator = { + pattern: /^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i, + message: "INVALID_ALPHA", + type: "regex" + }; + break; + case "alphaSpaces" : + case "alpha_spaces" : + validator = { + pattern: /^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i, + message: "INVALID_ALPHA_SPACE", + type: "regex" + }; + break; + case "alphaNum" : + case "alpha_num" : + validator = { + pattern: /^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i, + message: "INVALID_ALPHA_NUM", + type: "regex" + }; + break; + case "alphaNumSpaces" : + case "alpha_num_spaces" : + validator = { + pattern: /^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i, + message: "INVALID_ALPHA_NUM_SPACE", + type: "regex" + }; + break; + case "alphaDash" : + case "alpha_dash" : + validator = { + pattern: /^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i, + message: "INVALID_ALPHA_DASH", + type: "regex" + }; + break; + case "alphaDashSpaces" : + case "alpha_dash_spaces" : + validator = { + pattern: /^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i, + message: "INVALID_ALPHA_DASH_SPACE", + type: "regex" + }; + break; + case "between" : + case "range" : + var ranges = ruleParams.split(','); + if (ranges.length !== 2) { + throw "This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5"; + } + validator = { + patternLength: "^(.|[\\r\\n]){" + ranges[0] + "," + ranges[1] + "}$", + messageLength: "INVALID_BETWEEN_CHAR", + conditionNum: [">=","<="], + messageNum: "INVALID_BETWEEN_NUM", + params: [ranges[0], ranges[1]], + type: "autoDetect" + }; + break; + case "betweenLen" : + case "between_len" : + case "stringLen" : + case "string_len" : + case "stringLength" : + case "string_length" : + var ranges = ruleParams.split(','); + if (ranges.length !== 2) { + throw "This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5"; + } + validator = { + pattern: "^(.|[\\r\\n]){" + ranges[0] + "," + ranges[1] + "}$", + message: "INVALID_BETWEEN_CHAR", + params: [ranges[0], ranges[1]], + type: "regex" + }; + break; + case "betweenNum" : + case "between_num" : + var ranges = ruleParams.split(','); + if (ranges.length !== 2) { + throw "This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5"; + } + validator = { + condition: [">=","<="], + message: "INVALID_BETWEEN_NUM", + params: [ranges[0], ranges[1]], + type: "conditionalNumber" + }; + break; + case "boolean": + validator = { + pattern: /^(true|false|0|1)$/i, + message: "INVALID_BOOLEAN", + type: "regex" + }; + break; + case "checked": + validator = { + pattern: /^true$/i, + message: "INVALID_CHECKBOX_SELECTED", + type: "regex" + }; + break; + case "creditCard" : + case "credit_card" : + validator = { + pattern: /^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/, + message: "INVALID_CREDIT_CARD", + type: "regex" + }; + break; + case "custom" : + case "javascript" : + validator = { + message: '', // there is no error message defined on this one since user will provide his own error message via remote response or `alt=` + params: [ruleParams], + type: "javascript" + }; + break; + case "dateEuro" : + case "date_euro" : + validator = { + // accept long & short year (1996 or 96) + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_EURO", + type: "regex" + }; + break; + case "dateEuroBetween" : + case "date_euro_between" : + case "betweenDateEuro" : + case "between_date_euro" : + var ranges = ruleParams.split(','); + if (ranges.length !== 2) { + throw "This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015"; + } + validator = { + condition: [">=","<="], + dateType: "EURO_LONG", + params: [ranges[0], ranges[1]], + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_EURO_BETWEEN", + type: "conditionalDate" + }; + break; + case "dateEuroMax" : + case "date_euro_max" : + case "maxDateEuro" : + case "max_date_euro" : + validator = { + condition: "<=", + dateType: "EURO_LONG", + params: [ruleParams], + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_EURO_MAX", + type: "conditionalDate" + }; + break; + case "dateEuroMin" : + case "date_euro_min" : + case "minDateEuro" : + case "min_date_euro" : + validator = { + condition: ">=", + dateType: "EURO_LONG", + params: [ruleParams], + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_EURO_MIN", + type: "conditionalDate" + }; + break; + case "dateEuroLong" : + case "date_euro_long" : + validator = { + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, + message: "INVALID_DATE_EURO_LONG", + type: "regex" + }; + break; + case "dateEuroLongBetween" : + case "date_euro_long_between" : + case "betweenDateEuroLong" : + case "between_date_euro_long" : + var ranges = ruleParams.split(','); + if (ranges.length !== 2) { + throw "This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015"; + } + validator = { + condition: [">=","<="], + dateType: "EURO_LONG", + params: [ranges[0], ranges[1]], + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, + message: "INVALID_DATE_EURO_LONG_BETWEEN", + type: "conditionalDate" + }; + break; + case "dateEuroLongMax" : + case "date_euro_long_max" : + case "maxDateEuroLong" : + case "max_date_euro_long" : + validator = { + condition: "<=", + dateType: "EURO_LONG", + params: [ruleParams], + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, + message: "INVALID_DATE_EURO_LONG_MAX", + type: "conditionalDate" + }; + break; + case "dateEuroLongMin" : + case "date_euro_long_min" : + case "minDateEuroLong" : + case "min_date_euro_long" : + validator = { + condition: ">=", + dateType: "EURO_LONG", + params: [ruleParams], + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, + message: "INVALID_DATE_EURO_LONG_MIN", + type: "conditionalDate" + }; + break; + case "dateEuroShort" : + case "date_euro_short" : + validator = { + 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 ranges = ruleParams.split(','); + if (ranges.length !== 2) { + throw "This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15"; + } + validator = { + condition: [">=","<="], + dateType: "EURO_SHORT", + params: [ranges[0], ranges[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" : + validator = { + condition: "<=", + dateType: "EURO_SHORT", + params: [ruleParams], + 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" : + validator = { + condition: ">=", + dateType: "EURO_SHORT", + params: [ruleParams], + 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" : + validator = { + pattern: /^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/, + message: "INVALID_DATE_ISO", + type: "regex" + }; + break; + case "dateIsoBetween" : + case "date_iso_between" : + case "betweenDateIso" : + case "between_date_iso" : + var ranges = ruleParams.split(','); + if (ranges.length !== 2) { + throw "This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31"; + } + validator = { + condition: [">=","<="], + dateType: "ISO", + params: [ranges[0], ranges[1]], + pattern: /^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/, + message: "INVALID_DATE_ISO_BETWEEN", + type: "conditionalDate" + }; + break; + case "dateIsoMax" : + case "date_iso_max" : + case "maxDateIso" : + case "max_date_iso" : + validator = { + condition: "<=", + dateType: "ISO", + params: [ruleParams], + pattern: /^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/, + message: "INVALID_DATE_ISO_MAX", + type: "conditionalDate" + }; + break; + case "dateIsoMin" : + case "date_iso_min" : + case "minDateIso" : + case "min_date_iso" : + validator = { + condition: ">=", + dateType: "ISO", + params: [ruleParams], + pattern: /^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/, + message: "INVALID_DATE_ISO_MIN", + type: "conditionalDate" + }; + break; + case "dateUs" : + case "date_us" : + validator = { + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_US", + type: "regex" + }; + break; + case "dateUsBetween" : + case "date_us_between" : + case "betweenDateUs" : + case "between_date_us" : + var ranges = ruleParams.split(','); + if (ranges.length !== 2) { + throw "This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015"; + } + validator = { + condition: [">=","<="], + dateType: "US_LONG", + params: [ranges[0], ranges[1]], + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_US_BETWEEN", + type: "conditionalDate" + }; + break; + case "dateUsMax" : + case "date_us_max" : + case "maxDateUs" : + case "max_date_us" : + validator = { + condition: "<=", + dateType: "US_LONG", + params: [ruleParams], + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_US_MAX", + type: "conditionalDate" + }; + break; + case "dateUsMin" : + case "date_us_min" : + case "minDateUs" : + case "min_date_us" : + validator = { + condition: ">=", + dateType: "US_LONG", + params: [ruleParams], + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_US_MIN", + type: "conditionalDate" + }; + break; + case "dateUsLong" : + case "date_us_long" : + validator = { + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, + message: "INVALID_DATE_US_LONG", + type: "regex" + }; + break; + case "dateUsLongBetween" : + case "date_us_long_between" : + case "betweenDateUsLong" : + case "between_date_us_long" : + var ranges = ruleParams.split(','); + if (ranges.length !== 2) { + throw "This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015"; + } + validator = { + condition: [">=","<="], + dateType: "US_LONG", + params: [ranges[0], ranges[1]], + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, + message: "INVALID_DATE_US_LONG_BETWEEN", + type: "conditionalDate" + }; + break; + case "dateUsLongMax" : + case "date_us_long_max" : + case "maxDateUsLong" : + case "max_date_us_long" : + validator = { + condition: "<=", + dateType: "US_LONG", + params: [ruleParams], + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, + message: "INVALID_DATE_US_LONG_MAX", + type: "conditionalDate" + }; + break; + case "dateUsLongMin" : + case "date_us_long_min" : + case "minDateUsLong" : + case "min_date_us_long" : + validator = { + condition: ">=", + dateType: "US_LONG", + params: [ruleParams], + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, + message: "INVALID_DATE_US_LONG_MIN", + type: "conditionalDate" + }; + break; + case "dateUsShort" : + case "date_us_short" : + validator = { + 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 ranges = ruleParams.split(','); + if (ranges.length !== 2) { + throw "This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15"; + } + validator = { + condition: [">=","<="], + dateType: "US_SHORT", + params: [ranges[0], ranges[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" : + validator = { + condition: "<=", + dateType: "US_SHORT", + params: [ruleParams], + 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" : + validator = { + condition: ">=", + dateType: "US_SHORT", + params: [ruleParams], + 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 "different" : + case "differentInput" : + case "different_input" : + var args = ruleParams.split(','); + validator = { + condition: "!=", + message: "INVALID_INPUT_DIFFERENT", + params: args, + type: "matching" + }; + break; + case "digits" : + validator = { + pattern: "^\\d{" + ruleParams + "}$", + message: "INVALID_DIGITS", + params: [ruleParams], + type: "regex" + }; + break; + case "digitsBetween" : + case "digits_between" : + var ranges = ruleParams.split(','); + if (ranges.length !== 2) { + throw "This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5"; + } + validator = { + pattern: "^\\d{" + ranges[0] + "," + ranges[1] + "}$", + message: "INVALID_DIGITS_BETWEEN", + params: [ranges[0], ranges[1]], + type: "regex" + }; + break; + case "email" : + case "emailAddress" : + case "email_address" : + validator = { + // Email RFC 5322, pattern pulled from http://www.regular-expressions.info/email.html + // but removed necessity of a TLD (Top Level Domain) which makes this email valid: admin@mailserver1 + pattern: /^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i, + message: "INVALID_EMAIL", + type: "regex" + }; + break; + case "exactLen" : + case "exact_len" : + validator = { + pattern: "^(.|[\\r\\n]){" + ruleParams + "}$", + message: "INVALID_EXACT_LEN", + params: [ruleParams], + type: "regex" + }; + break; + case "float" : + validator = { + pattern: /^\d*\.{1}\d+$/, + message: "INVALID_FLOAT", + type: "regex" + }; + break; + case "floatSigned" : + case "float_signed" : + validator = { + pattern: /^[-+]?\d*\.{1}\d+$/, + message: "INVALID_FLOAT_SIGNED", + type: "regex" + }; + break; + case "iban" : + validator = { + pattern: /^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i, + message: "INVALID_IBAN", + type: "regex" + }; + break; + case "enum" : + case "in" : + case "inList" : + case "in_list" : + var list = RegExp().escape(ruleParams).replace(/,/g, '|'); // escape string & replace comma (,) by pipe (|) + validator = { + pattern: "^(" + list + ")$", + patternFlag: 'i', + message: "INVALID_IN_LIST", + params: [ruleParams], + type: "regex" + }; + break; + case "int" : + case "integer" : + validator = { + pattern: /^\d+$/, + message: "INVALID_INTEGER", + type: "regex" + }; + break; + case "intSigned" : + case "integerSigned" : + case "int_signed" : + case "integer_signed" : + validator = { + pattern: /^[+-]?\d+$/, + message: "INVALID_INTEGER_SIGNED", + type: "regex" + }; + break; + case "ip" : + case "ipv4" : + validator = { + 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" : + validator = { + pattern: /^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i, + message: "INVALID_IPV6", + type: "regex" + }; + break; + case "compare" : + case "match" : + case "matchInput" : + case "match_input" : + case "same" : + var args = ruleParams.split(','); + validator = { + condition: "===", + message: "INVALID_INPUT_MATCH", + params: args, + type: "matching" + }; + break; + case "max" : + validator = { + patternLength: "^(.|[\\r\\n]){0," + ruleParams + "}$", + messageLength: "INVALID_MAX_CHAR", + conditionNum: "<=", + messageNum: "INVALID_MAX_NUM", + params: [ruleParams], + type: "autoDetect" + }; + break; + case "maxLen" : + case "max_len" : + case "maxLength" : + case "max_length" : + validator = { + pattern: "^(.|[\\r\\n]){0," + ruleParams + "}$", + message: "INVALID_MAX_CHAR", + params: [ruleParams], + type: "regex" + }; + break; + case "maxNum" : + case "max_num" : + validator = { + condition: "<=", + message: "INVALID_MAX_NUM", + params: [ruleParams], + type: "conditionalNumber" + }; + break; + case "min" : + validator = { + patternLength: "^(.|[\\r\\n]){" + ruleParams + ",}$", + messageLength: "INVALID_MIN_CHAR", + conditionNum: ">=", + messageNum: "INVALID_MIN_NUM", + params: [ruleParams], + type: "autoDetect" + }; + break; + case "minLen" : + case "min_len" : + case "minLength" : + case "min_length" : + validator = { + pattern: "^(.|[\\r\\n]){" + ruleParams + ",}$", + message: "INVALID_MIN_CHAR", + params: [ruleParams], + type: "regex" + }; + break; + case "minNum" : + case "min_num" : + validator = { + condition: ">=", + message: "INVALID_MIN_NUM", + params: [ruleParams], + type: "conditionalNumber" + }; + break; + case "notIn" : + case "not_in" : + case "notInList" : + case "not_in_list" : + var list = RegExp().escape(ruleParams).replace(/,/g, '|'); // escape string & replace comma (,) by pipe (|) + validator = { + pattern: "^((?!(" + list + ")).)+$", + patternFlag: 'i', + message: "INVALID_NOT_IN_LIST", + params: [ruleParams], + type: "regex" + }; + break; + case "numeric" : + validator = { + pattern: /^\d*\.?\d+$/, + message: "INVALID_NUMERIC", + type: "regex" + }; + break; + case "numericSigned" : + case "numeric_signed" : + validator = { + pattern: /^[-+]?\d*\.?\d+$/, + message: "INVALID_NUMERIC_SIGNED", + type: "regex" + }; + break; + case "phone" : + validator = { + pattern: /^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/, + message: "INVALID_PHONE_US", + type: "regex" + }; + break; + case "phoneInternational" : + case "phone_international" : + validator = { + pattern: /^\+(?:[0-9]\x20?){6,14}[0-9]$/, + message: "INVALID_PHONE_INTERNATIONAL", + type: "regex" + }; + break; + case "pattern" : + case "regex" : + // Custom User Regex is a special case, the properties (message, pattern) were created and dealt separately prior to the for loop + validator = { + pattern: customUserRegEx.pattern, + message: "INVALID_PATTERN", + params: [customUserRegEx.message], + type: "regex" + }; + break; + case "remote" : + validator = { + message: '', // there is no error message defined on this one since user will provide his own error message via remote response or `alt=` + params: [ruleParams], + type: "remote" + }; + break; + case "required" : + validator = { + pattern: /\S+/, + message: "INVALID_REQUIRED", + type: "regex" + }; + break; + case "size" : + validator = { + patternLength: "^(.|[\\r\\n]){" + ruleParams + "}$", + messageLength: "INVALID_EXACT_LEN", + conditionNum: "==", + messageNum: "INVALID_EXACT_NUM", + params: [ruleParams], + type: "autoDetect" + }; + break; + case "url" : + validator = { + pattern: /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i, + message: "INVALID_URL", + type: "regex" + }; + break; + case "time" : + validator = { + pattern: /^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/, + message: "INVALID_TIME", + type: "regex" + }; + break; + } // switch() + + // add the possible alternate text user might have provided + validator.altText = alternateText; + + return validator; + } // getElementValidators() +}]); + +/** extend RegExp object to have an escape function + * @param string text + * @return escaped string + */ +RegExp.prototype.escape = function(text) { + if (!arguments.callee.sRE) { + var specials = [ + '/', '.', '*', '+', '?', '|', + '(', ')', '[', ']', '{', '}', '\\' + ]; + arguments.callee.sRE = new RegExp( + '(\\' + specials.join('|\\') + ')', 'g' + ); + } + return text.replace(arguments.callee.sRE, '\\$1'); +} +/** + * Angular-Validation Service (ghiscoding) + * https://github.com/ghiscoding/angular-validation + * + * @author: Ghislain B. + * @desc: angular-validation service definition + * Provide a way to programmatically create validators and validate a form directly from within the controller. + * This Service is totally independant from the Directive, it could be used separately but the minimum it needs is the `validation-rules.js` file. + */ +angular + .module('ghiscoding.validation') + .service('ValidationService', ['$interpolate', '$q', '$timeout', 'ValidationCommon', function ($interpolate, $q, $timeout, ValidationCommon) { + // global variables of our object (start with _var) + var _blurHandler; + var _watchers = []; + var _validateOnEmpty; + var _validationCallback; + var _globalOptions; + + // service constructor + var ValidationService = function (globalOptions) { + this.isValidationCancelled = false; // is the validation cancelled? + this.timer = null; // timer of user inactivity time + this.validationAttrs = {}; // Current Validator attributes + this.commonObj = new ValidationCommon(); // Object of validationCommon service + + // if global options were passed to the constructor + if (!!globalOptions) { + this.setGlobalOptions(globalOptions); + } + + _globalOptions = this.commonObj.getGlobalOptions(); + } + + // list of available published public functions of this object + ValidationService.prototype.addValidator = addValidator; // add a Validator to current element + 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.resetForm = resetForm; // reset the form (reset it to Pristine and Untouched) + ValidationService.prototype.setDisplayOnlyLastErrorMsg = setDisplayOnlyLastErrorMsg; // setter on the behaviour of displaying only the last error message + ValidationService.prototype.setGlobalOptions = setGlobalOptions; // set and initialize global options used by all validators + ValidationService.prototype.clearInvalidValidatorsInSummary = clearInvalidValidatorsInSummary; // clear clearInvalidValidatorsInSummary + + return ValidationService; + + //---- + // Public Functions declaration + //---------------------------------- + + /** Add a validator on a form element, the argument could be passed as 1 single object (having all properties) or 2 to 3 string arguments + * @param mixed var1: could be a string (element name) or an object representing the validator + * @param string var2: [optional] validator rules + * @param string var3: [optional] friendly name + */ + function addValidator(var1, var2, var3) { + var self = this; + var attrs = {}; + + // find if user provided 2 string arguments else it will be a single object with all properties + if(typeof var1 === "string" && typeof var2 === "string") { + attrs.elmName = var1; + attrs.rules = var2; + attrs.friendlyName = (typeof var3 === "string") ? var3 : ''; + }else { + attrs = var1; + } + + // Make sure that we have all required attributes to work properly + if(typeof attrs !== "object" || !attrs.hasOwnProperty('elmName') || !attrs.hasOwnProperty('rules') || (!attrs.hasOwnProperty('scope') && typeof self.validationAttrs.scope === "undefined") ) { + throw 'Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}'; + } + + // get the scope from the validator or from the global options (validationAttrs) + var scope = (!!attrs.scope) ? attrs.scope : self.validationAttrs.scope; + + // find the DOM element & make sure it's a filled object before going further + // we will exclude disabled/ng-disabled element from being validated + attrs.elm = angular.element(document.querySelector('[name="'+attrs.elmName+'"]')); + if(typeof attrs.elm !== "object" || attrs.elm.length === 0) { + return self; + } + + // copy the element attributes name to use throughout validationCommon + // when using dynamic elements, we might have encounter unparsed or uncompiled data, we need to get Angular result with $interpolate + if(new RegExp("{{(.*?)}}").test(attrs.elmName)) { + attrs.elmName = $interpolate(attrs.elmName)(scope); + } + 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(!!tempValidationOptions) { + 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 + var formElmObj = self.commonObj.getFormElementByName(attrs.elmName); + + if (!!formElmObj && !formElmObj.isValidationCancelled) { + // re-initialize to use current element & validate without delay + self.commonObj.initialize(scope, attrs.elm, attrs, attrs.ctrl); + + // attempt to validate & run validation callback if user requested it + var validationPromise = attemptToValidate(self, event.target.value, 0); + if(!!_validationCallback) { + self.commonObj.runValidationCallbackOnPromise(validationPromise, _validationCallback); + } + } + }); + + // merge both attributes but 2nd object (attrs) as higher priority, so that for example debounce property inside `attrs` as higher priority over `validatorAttrs` + // so the position inside the mergeObject call is very important + attrs = self.commonObj.mergeObjects(self.validationAttrs, attrs); + + // 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); + + // if DOM element gets destroyed, we need to cancel validation, unbind onBlur & remove it from $validationSummary + attrs.elm.on('$destroy', function() { + // get the form element custom object and use it after + var formElmObj = self.commonObj.getFormElementByName(self.commonObj.ctrl.$name); + + // unbind everything and cancel the validation + if(!!formElmObj) { + cancelValidation(self, formElmObj); + self.commonObj.removeFromValidationSummary(attrs.name); + } + }); + + // save the watcher inside an array in case we want to deregister it when removing a validator + _watchers.push({ elmName: attrs.elmName, watcherHandler: createWatch(scope, attrs, self) }); + + return self; + } // addValidator() + + /** Check the form validity (can be called by an empty ValidationService and used by both Directive/Service) + * Loop through Validation Summary and if any errors found then display them and return false on current function + * @param object Angular Form or Scope Object + * @param bool silently, do a form validation silently + * @return bool isFormValid + */ + function checkFormValidity(obj, silently) { + var self = this; + var ctrl, elm, elmName = '', isValid = true; + if(typeof obj === "undefined" || typeof obj.$validationSummary === "undefined") { + throw 'checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)'; + } + + // loop through $validationSummary and display errors when found on each field + for(var i = 0, ln = obj.$validationSummary.length; i < ln; i++) { + isValid = false; + elmName = obj.$validationSummary[i].field; + + if(!!elmName) { + // get the form element custom object and use it after + var formElmObj = self.commonObj.getFormElementByName(elmName); + + if(!!formElmObj && !!formElmObj.elm && formElmObj.elm.length > 0) { + // make the element as it was touched for CSS, only works in AngularJS 1.3+ + if (typeof formElmObj.ctrl.$setTouched === "function" && !silently) { + formElmObj.ctrl.$setTouched(); + } + self.commonObj.updateErrorMsg(obj.$validationSummary[i].message, { isSubmitted: (!!silently ? false : true), isValid: formElmObj.isValid, obj: formElmObj }); + } + } + } + return isValid; + } + + /** 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. + * In this case you need to remove invalid validators that will exist in 'the future'. + * @param object Angular Form or Scope Object + */ + function clearInvalidValidatorsInSummary(obj) { + var self = this; + if (typeof obj === "undefined" || typeof obj.$validationSummary === "undefined") { + throw 'clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)'; + } + // Get list of names to remove + var elmName = []; + for (var i = 0, ln = obj.$validationSummary.length; i < ln; i++) { + elmName.push(obj.$validationSummary[i].field); + } + // Loop on list of names. Cannot loop on obj.$validationSummary as you are removing objects from it in the loop. + for (i = 0, ln = elmName.length; i < ln; i++) { + if (!!elmName[i]) { + self.commonObj.removeFromFormElementObjectList(elmName[i]); + self.commonObj.removeFromValidationSummary(elmName[i], obj.$validationSummary); + } + } + } + + /** Remove a validator and also any withstanding error message from that element + * @param object Angular Form or Scope Object + * @param object arguments that could be passed to the function + * @return object self + */ + function removeValidator(obj, args) { + var self = this; + var formElmObj; + + if(typeof obj === "undefined" || typeof obj.$validationSummary === "undefined") { + throw 'removeValidator() only works with Validation that were defined by the Service (not by the Directive) and requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)'; + } + + // Note: removeAttr() will remove validation attribute from the DOM (if defined by Directive), but as no effect when defined by the Service + // removeValidator() 2nd argument could be passed an Array or a string of element name(s) + // if it's an Array we will loop through all elements to be removed + // else just remove the 1 element defined as a string + if (args instanceof Array) { + for (var i = 0, ln = args.length; i < ln; i++) { + formElmObj = self.commonObj.getFormElementByName(args[i]); + formElmObj.elm.removeAttr('validation'); + removeWatcherAndErrorMessage(self, formElmObj, obj.$validationSummary); + } + } + else if(args instanceof Object && !!args.formElmObj) { + formElmObj = args.formElmObj; + formElmObj.elm.removeAttr('validation'); + removeWatcherAndErrorMessage(args.self, formElmObj, obj.$validationSummary); + } + else { + formElmObj = self.commonObj.getFormElementByName(args); + formElmObj.elm.removeAttr('validation'); + removeWatcherAndErrorMessage(self, formElmObj, obj.$validationSummary); + } + + return self; + } + + /** Reset a Form, reset all input element to Pristine, Untouched & remove error dislayed (if any) + * @param object Angular Form or Scope Object + * @param object arguments that could be passed to the function + */ + function resetForm(obj, args) { + var self = this; + var formElmObj; + var args = args || {}; + var shouldRemoveValidator = (typeof args.removeAllValidators !== "undefined") ? args.removeAllValidators : false; + var shouldEmptyValues = (typeof args.emptyAllInputValues !== "undefined") ? args.emptyAllInputValues : false; + + if(typeof obj === "undefined" || typeof obj.$name === "undefined") { + throw 'resetForm() requires a valid Angular Form object passed as argument to work properly (ex.: $scope.form1).'; + } + + // get all Form input elements and loop through all of them to set them Pristine, Untouched and also remove errors displayed + var formElements = self.commonObj.getFormElements(obj.$name); + if(formElements instanceof Array) { + for (var i = 0, ln = formElements.length; i < ln; i++) { + formElmObj = formElements[i]; + + // should we empty input elment values as well? + if(!!shouldEmptyValues) { + formElmObj.elm.val(null); + } + + // should we remove all validators? + // if yes, then run removeValidator() and since that already removes message & make input valid, no need to run the $setUntouched() and $setPristine() + // else make the field $setUntouched() and $setPristine() + if(!!shouldRemoveValidator) { + removeValidator(obj, { self: self, formElmObj: formElmObj}); + }else { + // make the element as it was touched for CSS, only works in AngularJS 1.3+ + if (typeof formElmObj.ctrl.$setUntouched === "function") { + formElmObj.ctrl.$setUntouched(); + } + formElmObj.ctrl.$setPristine(); + self.commonObj.updateErrorMsg('', { isValid: false, obj: formElmObj }); + } + } + } + } + + /** Setter on the behaviour of displaying only the last error message of each element. + * By default this is false, so the behavior is to display all error messages of each element. + * @param boolean value + */ + function setDisplayOnlyLastErrorMsg(boolValue) { + var self = this; + var isDisplaying = (typeof boolValue === "boolean") ? boolValue : true; + self.commonObj.setDisplayOnlyLastErrorMsg(isDisplaying); + } + + /** Set and initialize global options used by all validators + * @param object: global options + * @return object self + */ + function setGlobalOptions(options) { + var self = this; + self.validationAttrs = options; // save in global + self.commonObj.setGlobalOptions(options); + + return self; + } + + //---- + // Private functions declaration + //---------------------------------- + + /** Validator function to attach to the element, this will get call whenever the input field is updated + * and is also customizable through the (typing-limit) for which inactivity this.timer will trigger validation. + * @param object self + * @param string value: value of the input field + * @param int typingLimit: when user stop typing, in how much time it will start validating + * @return object validation promise + */ + function attemptToValidate(self, value, typingLimit) { + var deferred = $q.defer(); + var isValid = false; + + // get the waiting delay time if passed as argument or get it from common Object + var waitingLimit = (typeof typingLimit !== "undefined") ? typingLimit : self.commonObj.typingLimit; + + // get the form element custom object and use it after + var formElmObj = self.commonObj.getFormElementByName(self.commonObj.ctrl.$name); + + // if a field holds invalid characters which are not numbers inside an `input type="number"`, then it's automatically invalid + // we will still call the `.validate()` function so that it shows also the possible other error messages + if(!!value && !!value.badInput) { + return invalidateBadInputField(self, attrs.name); + } + + // pre-validate without any events just to pre-fill our validationSummary with all field errors + // passing false as 2nd argument for not showing any errors on screen + self.commonObj.validate(value, false); + + // if field is not required and his value is empty, cancel validation and exit out + if(!self.commonObj.isFieldRequired() && !_validateOnEmpty && (value === "" || value === null || typeof value === "undefined")) { + cancelValidation(self, formElmObj); + deferred.resolve({ isFieldValid: true, formElmObj: formElmObj, value: value }); + return deferred.promise; + }else { + formElmObj.isValidationCancelled = false; + } + + // invalidate field before doing any validation + if(!!value || self.commonObj.isFieldRequired() || _validateOnEmpty) { + self.commonObj.ctrl.$setValidity('validation', false); + } + + // if a field holds invalid characters which are not numbers inside an `input type="number"`, then it's automatically invalid + // we will still call the `.validate()` function so that it shows also the possible other error messages + if((value === "" || typeof value === "undefined") && self.commonObj.elm.prop('type').toUpperCase() === "NUMBER") { + $timeout.cancel(self.timer); + isValid = self.commonObj.validate(value, true); + deferred.resolve({ isFieldValid: isValid, formElmObj: formElmObj, value: value }); + return deferred.promise; + } + + // select(options) will be validated on the spot + if(self.commonObj.elm.prop('tagName').toUpperCase() === "SELECT") { + isValid = self.commonObj.validate(value, true); + self.commonObj.ctrl.$setValidity('validation', isValid); + deferred.resolve({ isFieldValid: isValid, formElmObj: formElmObj, value: value }); + return deferred.promise; + } + + // onKeyDown event is the default of Angular, no need to even bind it, it will fall under here anyway + // in case the field is already pre-filled, we need to validate it without looking at the event binding + if(typeof value !== "undefined") { + // when no timer, validate right away without a $timeout. This seems quite important on the array input value check + if(typingLimit === 0) { + isValid = self.commonObj.validate(value, true); + self.commonObj.scope.$evalAsync(self.commonObj.ctrl.$setValidity('validation', isValid )); + deferred.resolve({ isFieldValid: isValid, formElmObj: formElmObj, value: value }); + $timeout.cancel(self.timer); + }else { + // Make the validation only after the user has stopped activity on a field + // everytime a new character is typed, it will cancel/restart the timer & we'll erase any error mmsg + self.commonObj.updateErrorMsg(''); + $timeout.cancel(self.timer); + self.timer = $timeout(function() { + isValid = self.commonObj.validate(value, true); + self.commonObj.scope.$evalAsync(self.commonObj.ctrl.$setValidity('validation', isValid )); + deferred.resolve({ isFieldValid: isValid, formElmObj: formElmObj, value: value }); + }, waitingLimit); + } + } + + return deferred.promise; + } // attemptToValidate() + + /** Cancel current validation test and blank any leftover error message + * @param object obj + * @param object formElmObj: form element object + */ + function cancelValidation(obj, formElmObj) { + // get the form element custom object and use it after + var ctrl = (!!formElmObj && !!formElmObj.ctrl) ? formElmObj.ctrl : obj.commonObj.ctrl; + + if(!!formElmObj) { + formElmObj.isValidationCancelled = true; + } + $timeout.cancel(self.timer); + ctrl.$setValidity('validation', true); + obj.commonObj.updateErrorMsg('', { isValid: true, obj: formElmObj }); + + // unbind onBlur handler (if found) so that it does not fail on a non-required element that is now dirty & empty + unbindBlurHandler(obj, formElmObj); + } + + /** watch the element for any value change, validate it once that happen + * @return new watcher + */ + function createWatch(scope, attrs, self) { + return scope.$watch(function() { + attrs.ctrl = angular.element(attrs.elm).controller('ngModel'); + + if(isKeyTypedBadInput(self, attrs.elmName)) { + return { badInput: true }; + } + return attrs.ctrl.$modelValue; + }, function (newValue, oldValue) { + if(!!newValue && !!newValue.badInput) { + var formElmObj = self.commonObj.getFormElementByName(attrs.elmName); + unbindBlurHandler(self, formElmObj); + return invalidateBadInputField(self, attrs.name); + } + // when previous value was set and new value is not, this is most probably an invalid character entered in a type input="text" + // we will still call the `.validate()` function so that it shows also the possible other error messages + if(newValue === undefined && (oldValue !== undefined && !isNaN(oldValue))) { + $timeout.cancel(self.timer); + self.commonObj.ctrl.$setValidity('validation', self.commonObj.validate('', true)); + return; + } + // from the DOM element, find the Angular controller of this element & add value as well to list of attribtues + attrs.ctrl = angular.element(attrs.elm).controller('ngModel'); + attrs.value = newValue; + + self.commonObj.initialize(scope, attrs.elm, attrs, attrs.ctrl); + + var waitingTimer = (typeof newValue === "undefined" || (typeof newValue === "number" && isNaN(newValue))) ? 0 : undefined; + // attempt to validate & run validation callback if user requested it + var validationPromise = attemptToValidate(self, newValue, waitingTimer); + if(!!_validationCallback) { + self.commonObj.runValidationCallbackOnPromise(validationPromise, _validationCallback); + } + }, true); // $watch() + } + + /** Invalidate the field that was tagged as bad input, cancel the timer validation, + * display an invalid key error and add it as well to the validation summary. + * @param object self + * @param string: element input name + */ + function invalidateBadInputField(self, elmName) { + $timeout.cancel(self.timer); + var formElmObj = self.commonObj.getFormElementByName(elmName); + self.commonObj.updateErrorMsg('INVALID_KEY_CHAR', { isValid: false, translate: true, obj: formElmObj }); + self.commonObj.addToValidationSummary(formElmObj, 'INVALID_KEY_CHAR', true); + } + + /** Was the characters typed by the user bad input or not? + * @param object self + * @param string: element input name + * @return bool + */ + function isKeyTypedBadInput(self, elmName) { + var formElmObj = self.commonObj.getFormElementByName(elmName); + return (!!formElmObj && !!formElmObj.elm.prop('validity') && formElmObj.elm.prop('validity').badInput === true); + } + + /** Remove a watcher and any withstanding error message from the element + * @param object self + * @param object formElmObj: form element object + * @param object validationSummary + */ + function removeWatcherAndErrorMessage(self, formElmObj, validationSummary) { + var scope = + !!self.commonObj.scope + ? self.commonObj.scope + : !!formElmObj.scope + ? formElmObj.scope + : null; + if(typeof scope === "undefined") { + throw 'removeValidator() requires a valid $scope object passed but unfortunately could not find it.'; + } + + // deregister the $watch from the _watchers array we kept it + var foundWatcher = self.commonObj.arrayFindObject(_watchers, 'elmName', formElmObj.fieldName); + if(!!foundWatcher) { + foundWatcher.watcherHandler(); // deregister the watch by calling his handler + _watchers.shift(); + } + + // make the validation cancelled so it won't get called anymore in the blur eventHandler + formElmObj.isValidationCancelled = true; + formElmObj.isValid = true; + formElmObj.attrs.validation = ""; + cancelValidation(self, formElmObj); + + // now to remove any errors, we need to make the element untouched, pristine and remove the validation + // also remove it from the validationSummary list and remove any displayed error + if (typeof formElmObj.ctrl.$setUntouched === "function") { + // make the element untouched in CSS, only works in AngularJS 1.3+ + formElmObj.ctrl.$setUntouched(); + } + self.commonObj.scope = scope; + formElmObj.ctrl.$setPristine(); + self.commonObj.removeFromValidationSummary(formElmObj.fieldName, validationSummary); + } + + /** If found unbind the blur hanlder + * @param object self + * @param object formElmObj: form element object + */ + function unbindBlurHandler(obj, formElmObj) { + formElmObj.isValidationCancelled = true; + if(typeof _blurHandler === "function") { + var elm = (!!formElmObj && !!formElmObj.elm) ? formElmObj.elm : obj.commonObj.elm; + elm.unbind('blur', _blurHandler); + } + } + + /** Watch for an disabled/ngDisabled attribute change, + * if it become disabled then skip validation else it becomes enable then we need to revalidate it + * @param object self + * @param object scope + * @param object attributes + */ + function watchNgDisabled(self, scope, attrs) { + scope.$watch(function() { + return (typeof attrs.elm.attr('ng-disabled') === "undefined") ? null : scope.$eval(attrs.elm.attr('ng-disabled')); //this will evaluate attribute value `{{}}`` + }, function(disabled) { + if(typeof disabled === "undefined" || disabled === null) { + return null; + } + + // get current ctrl of element & re-initialize to use current element + attrs.ctrl = angular.element(attrs.elm).controller('ngModel'); + self.commonObj.initialize(scope, attrs.elm, attrs, attrs.ctrl); + + // get the form element custom object and use it after + var formElmObj = self.commonObj.getFormElementByName(attrs.name); + + // use a timeout so that the digest of removing the `disabled` attribute on the DOM is completed + // because commonObj.validate() checks for both the `disabled` and `ng-disabled` attribute so it basically fails without the $timeout because of the digest + $timeout(function() { + var isDisabled = (disabled === "") + ? true + : (typeof disabled === "boolean") ? disabled + : (typeof disabled !== "undefined") ? scope.$eval(disabled) : false; + + if (isDisabled) { + // Remove it from validation summary + attrs.ctrl.$setValidity('validation', true); + self.commonObj.updateErrorMsg('', { isValid: true, obj: formElmObj }); + self.commonObj.removeFromValidationSummary(attrs.name); + } else { + // Re-Validate the input when enabled (without displaying the error) + var value = attrs.ctrl.$viewValue || ''; + + // re-initialize to use current element & validate without delay (without displaying the error) + self.commonObj.initialize(scope, attrs.elm, attrs, attrs.ctrl); + attrs.ctrl.$setValidity('validation', self.commonObj.validate(value, false)); + + // make sure it's re-enable the validation as well + if(!!formElmObj) { + formElmObj.isValidationCancelled = false; + } + + // re-attach the onBlur handler + attrs.elm.bind('blur', _blurHandler = function(event) { + if (!!formElmObj && !formElmObj.isValidationCancelled) { + // attempt to validate & run validation callback if user requested it + var validationPromise = attemptToValidate(self, event.target.value, 10); + if(!!_validationCallback) { + self.commonObj.runValidationCallbackOnPromise(validationPromise, _validationCallback); + } + } + }); + } + }, 0, false); + + // these cannot be done inside the $timeout, when doing it would cancel validation for all element because of the delay + if (disabled) { + // Turn off validation when element is disabled & remove from validationSummary (seems I need to remove from summary inside $timeout and outside) + // make the element as it was untouched for CSS, only works in AngularJS 1.3+ + if (typeof attrs.ctrl.$setUntouched === "function") { + attrs.ctrl.$setUntouched(); + } + attrs.ctrl.$setValidity('validation', true); + self.commonObj.removeFromValidationSummary(attrs.name); + } + }); + } + +}]); // ValidationService \ No newline at end of file diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 618e84c..76f8a0d 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.5.19 + * @version: 1.5.20 * @license: MIT - * @build: Mon Apr 17 2017 23:41:06 GMT-0400 (Eastern Daylight Time) + * @build: Thu Apr 20 2017 12:18:09 GMT-0400 (Eastern Daylight Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(A){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&$.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&$.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,A=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){var e=""===a||("boolean"==typeof a?a:"undefined"!=typeof a&&n.$eval(a));e===!0?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue,n=$.getFormElementByName(l.$name);if(n&&n.hasOwnProperty("isValidationCancelled")){var t=o(i);w&&$.runValidationCallbackOnPromise(t,w)}else l.$setValidity("validation",!0)}})}}}]); angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=V(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Q[o]=l:Q.push(l)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs&&K.controllerAs[u]?K.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;p&&(p.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function s(e){return e?A(z,"formName",e):z}function l(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=V(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=V(n,"field",e);if(i>=0&&n.splice(i,1),i=V(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(s):n.after('
'+s+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,s=!0,l=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+(n&&n.params?String.format(a,n.params):a):p.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+o:p.message+=s+o,O(i,e,p.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=V(z,"fieldName",e.attr("name"));return u>=0?z[u]=l:z.push(l),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=l.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[l]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,p,d)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var l=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=M(t.condition[0],s,l),d=M(t.condition[1],s,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=M(t.condition,s,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)s=!!d;else{if("object"!=typeof d)throw u;s=!!d.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return s}function H(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=M(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=M(p.condition,d.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=p.message;p.altText&&p.altText.length>0&&(o=p.altText.replace("alt=","")),a(o).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,i,!0)})}d.$setValidity("validation",i)}},!0),i}function I(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();d&&"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled,o=r.elm.prop("disabled"),s=""===o||("boolean"==typeof o?o:"undefined"!=typeof o&&r.scope.$eval(o)),l=""===i||("boolean"==typeof i?i:"undefined"!=typeof i&&r.scope.$eval(i));if(s||l)n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var u=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&u.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=s,X.prototype.getGlobalOptions=l,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; -angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return g=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,$=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);g&&n.commonObj.runValidationCallbackOnPromise(t,g)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e,o){var t=this,a="",n=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var i=0,l=e.$validationSummary.length;i0&&("function"!=typeof m.ctrl.$setTouched||o||m.ctrl.$setTouched(),t.commonObj.updateErrorMsg(e.$validationSummary[i].message,{isSubmitted:!o,isValid:m.isValid,obj:m}))}return n}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a0&&("function"!=typeof m.ctrl.$setTouched||o||m.ctrl.$setTouched(),t.commonObj.updateErrorMsg(e.$validationSummary[i].message,{isSubmitted:!o,isValid:m.isValid,obj:m}))}return n}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a Date: Thu, 20 Apr 2017 12:22:09 -0400 Subject: [PATCH 34/60] update changelog --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index e088f53..a31f2d2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.20 (2017-04-20) Add an unminified version and Fix #153 bug in validation service. 1.5.19 (2017-04-17) Fix #150 angularValidation.revalidate problems 1.5.18 (2017-03-31) Fix disabled="false" as attribute to run validation. 1.5.17 (2017-03-10) Add silent mode to checkFormValidity function From 25993a6a3cd44a68b0bd5e93ccfd8adf21409ad6 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Mon, 15 May 2017 00:51:42 -0400 Subject: [PATCH 35/60] Fix #151 validation rule "different" makes "required" not enforced --- bower.json | 2 +- dist/angular-validation.js | 13 ++++++++----- dist/angular-validation.min.js | 6 +++--- package.json | 2 +- readme.md | 2 +- src/validation-common.js | 9 ++++++--- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/bower.json b/bower.json index 110ecee..c18636e 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.20", + "version": "1.5.21", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/dist/angular-validation.js b/dist/angular-validation.js index 323f9fc..124ef27 100644 --- a/dist/angular-validation.js +++ b/dist/angular-validation.js @@ -2,9 +2,9 @@ * Angular-Validation Directive and Service (ghiscoding) * http://github.com/ghiscoding/angular-validation * @author: Ghislain B. - * @version: 1.5.20 + * @version: 1.5.21 * @license: MIT - * @build: Thu Apr 20 2017 12:18:09 GMT-0400 (Eastern Daylight Time) + * @build: Sun May 14 2017 23:35:23 GMT-0400 (Eastern Daylight Time) */ /** * Angular-Validation Directive (ghiscoding) @@ -949,7 +949,6 @@ angular var nbValid = 0; var validator; var validatedObject = {}; - // make an object to hold the message so that we can reuse the object by reference // in some of the validation check (for example "matching" and "remote") var validationElmObj = { @@ -1720,7 +1719,9 @@ angular var matchingCtrl = self.ctrl; // keep reference of matching confirmation controller var formElmMatchingObj = getFormElementByName(self.ctrl.$name); - isValid = (testCondition(validator.condition, strValue, parentNgModelVal) && !!strValue); + isValid = ((!validator.pattern || validator.pattern.toString() === "/\\S+/" || (!!rules && validator.pattern === "required")) && strValue === null) + ? false + : (testCondition(validator.condition, strValue, parentNgModelVal) && !!strValue); // if element to compare against has a friendlyName or if matching 2nd argument was passed, we will use that as a new friendlyName // ex.: :: we would use the friendlyName of 'Password1' not input1 @@ -1734,7 +1735,9 @@ angular // Watch for the parent ngModel, if it change we need to re-validate the child (confirmation) self.scope.$watch(parentNgModel, function(newVal, oldVal) { - var isWatchValid = testCondition(matchingValidator.condition, matchingCtrl.$viewValue, newVal); + var isWatchValid = ((!validator.pattern || validator.pattern.toString() === "/\\S+/" || (!!rules && validator.pattern === "required")) && strValue === null) + ? false + : (testCondition(validator.condition, strValue, parentNgModelVal) && !!strValue); // only inspect on a parent input value change if(newVal !== oldVal) { diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 76f8a0d..45b6cd1 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.5.20 + * @version: 1.5.21 * @license: MIT - * @build: Thu Apr 20 2017 12:18:09 GMT-0400 (Eastern Daylight Time) + * @build: Sun May 14 2017 23:35:23 GMT-0400 (Eastern Daylight Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(A){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&$.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&$.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,A=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){var e=""===a||("boolean"==typeof a?a:"undefined"!=typeof a&&n.$eval(a));e===!0?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue,n=$.getFormElementByName(l.$name);if(n&&n.hasOwnProperty("isValidationCancelled")){var t=o(i);w&&$.runValidationCallbackOnPromise(t,w)}else l.$setValidity("validation",!0)}})}}}]); -angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=V(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?Q[o]=l:Q.push(l)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs&&K.controllerAs[u]?K.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;p&&(p.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",s=i.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function s(e){return e?A(z,"formName",e):z}function l(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=V(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=V(n,"field",e);if(i>=0&&n.splice(i,1),i=V(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(s):n.after('
'+s+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,s=!0,l=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+(n&&n.params?String.format(a,n.params):a):p.message+=s+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,l,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=s+o:p.message+=s+o,O(i,e,p.message,l,t)})}(m,s,r)),s&&u++,i.validRequireHowMany==u&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:i,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=V(z,"fieldName",e.attr("name"));return u>=0?z[u]=l:z.push(l),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=l.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[l]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,s-1,l,u,p,d)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,s=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var l=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=M(t.condition[0],s,l),d=M(t.condition[1],s,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=M(t.condition,s,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)s=!!d;else{if("object"!=typeof d)throw u;s=!!d.isValid}if(s===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return s}function H(e,t,r,n){var i=!0,s=t.params[0],l=r.scope.$eval(s),u=angular.element(document.querySelector('[name="'+s+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=M(t.condition,e,l)&&!!e,u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var i=M(p.condition,d.$viewValue,e);if(e!==t){if(i)O(r,m,"",!0,!0);else{m.isValid=!1;var o=p.message;p.altText&&p.altText.length>0&&(o=p.altText.replace("alt=","")),a(o).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,i,!0)})}d.$setValidity("validation",i)}},!0),i}function I(e,t,a,r,n,i){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();d&&"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw s;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled,o=r.elm.prop("disabled"),s=""===o||("boolean"==typeof o?o:"undefined"!=typeof o&&r.scope.$eval(o)),l=""===i||("boolean"==typeof i?i:"undefined"!=typeof i&&r.scope.$eval(i));if(s||l)n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var u=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&u.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=s,X.prototype.getGlobalOptions=l,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); +angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=E(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var l=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",s={field:n,friendlyName:l,message:t,formName:i?i.$name:null};o>=0?Q[o]=s:Q.push(s)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs&&K.controllerAs[u]?K.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;p&&(p.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",l=i.match(new RegExp("^/(.*?)/([gimy]*)$")),s=new RegExp(l[1],l[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:s},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function l(e){return e?A(z,"formName",e):z}function s(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=E(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=E(n,"field",e);if(i>=0&&n.splice(i,1),i=E(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var l=t&&t.translate?a.instant(e):e;l=l.trim();var s=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+s)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(l):n.after('
'+l+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,l=!0,s=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=l+(n&&n.params?String.format(a,n.params):a):p.message+=l+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,s,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=l+o:p.message+=l+o,O(i,e,p.message,s,t)})}(m,l,r)),l&&u++,i.validRequireHowMany==u&&l){s=!0;break}}return l&&(n(i,""),i.updateErrorMsg("",{isValid:l})),m&&(m.isValid=s,s&&(m.message="")),s}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),l=t&&t.friendlyName?a.instant(t.friendlyName):"",s={fieldName:i,friendlyName:l,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=E(z,"fieldName",e.attr("name"));return u>=0?z[u]=s:z.push(s),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=s.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[s]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],l=n[1],s=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,l-1,s,u,p,d)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,l=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var s=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=M(t.condition[0],l,s),d=M(t.condition[1],l,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=M(t.condition,l,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var l=!0,s="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)l=!!d;else{if("object"!=typeof d)throw u;l=!!d.isValid}if(l===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw s;O(r,n,e,!1,i)})):l===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return l}function H(e,t,r,n){var i=!0,l=t.params[0],s=r.scope.$eval(l),u=angular.element(document.querySelector('[name="'+l+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(M(t.condition,e,s)&&!!e),u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(l,function(i,o){var l=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(M(t.condition,e,s)&&!!e);if(i!==o){if(l)O(r,m,"",!0,!0);else{m.isValid=!1;var u=p.message;p.altText&&p.altText.length>0&&(u=p.altText.replace("alt=","")),a(u).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,l,!0)})}d.$setValidity("validation",l)}},!0),i}function I(e,t,a,r,n,i){var o=!0,l="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",s="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();d&&"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw s;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw s;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw l;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled,o=r.elm.prop("disabled"),l=""===o||("boolean"==typeof o?o:"undefined"!=typeof o&&r.scope.$eval(o)),s=""===i||("boolean"==typeof i?i:"undefined"!=typeof i&&r.scope.$eval(i));if(l||s)n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var u=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&u.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=l,X.prototype.getGlobalOptions=s,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return g=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,$=n.validationAttrs.hasOwnProperty("validateOnEmpty")?n.commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);g&&n.commonObj.runValidationCallbackOnPromise(t,g)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e,o){var t=this,a="",n=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var i=0,l=e.$validationSummary.length;i0&&("function"!=typeof m.ctrl.$setTouched||o||m.ctrl.$setTouched(),t.commonObj.updateErrorMsg(e.$validationSummary[i].message,{isSubmitted:!o,isValid:m.isValid,obj:m}))}return n}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a :: we would use the friendlyName of 'Password1' not input1 @@ -1295,7 +1296,9 @@ angular // Watch for the parent ngModel, if it change we need to re-validate the child (confirmation) self.scope.$watch(parentNgModel, function(newVal, oldVal) { - var isWatchValid = testCondition(matchingValidator.condition, matchingCtrl.$viewValue, newVal); + var isWatchValid = ((!validator.pattern || validator.pattern.toString() === "/\\S+/" || (!!rules && validator.pattern === "required")) && strValue === null) + ? false + : (testCondition(validator.condition, strValue, parentNgModelVal) && !!strValue); // only inspect on a parent input value change if(newVal !== oldVal) { From d0e330e125b7acf6260f738f14392eb90a7243fd Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Mon, 15 May 2017 00:54:04 -0400 Subject: [PATCH 36/60] update changelog --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index a31f2d2..0a4aea3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.21 (2017-05-14) Fix #151 validation rule "different" disables rule "required". 1.5.20 (2017-04-20) Add an unminified version and Fix #153 bug in validation service. 1.5.19 (2017-04-17) Fix #150 angularValidation.revalidate problems 1.5.18 (2017-03-31) Fix disabled="false" as attribute to run validation. From 1cf429cbcfa083fc1f76c61604f47b03f59a5ea8 Mon Sep 17 00:00:00 2001 From: wbiz Date: Wed, 7 Jun 2017 22:17:35 +1000 Subject: [PATCH 37/60] support simplified Chinese --- locales/validation/zh_CN.json | 105 ++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 locales/validation/zh_CN.json diff --git a/locales/validation/zh_CN.json b/locales/validation/zh_CN.json new file mode 100644 index 0000000..f428d4f --- /dev/null +++ b/locales/validation/zh_CN.json @@ -0,0 +1,105 @@ +{ + "INVALID_ACCEPTED": "必须接受。 ", + "INVALID_ALPHA": "可能只包含字母。 ", + "INVALID_ALPHA_SPACE": "可能只包含字母和空格。 ", + "INVALID_ALPHA_NUM": "可能只包含字母和数字。 ", + "INVALID_ALPHA_NUM_SPACE": "只能包含字母,数字和空格。 ", + "INVALID_ALPHA_DASH": "只能包含字母,数字和破折号。 ", + "INVALID_ALPHA_DASH_SPACE": "可能只包含字母,数字,破折号和空格。 ", + "INVALID_BETWEEN_CHAR": "文本长度必须在{0}和{1}个字符之间。 ", + "INVALID_BETWEEN_NUM": "需要是{0}到{1}之间的数值。 ", + "INVALID_BOOLEAN": "可能只包含真实或虚假的价值。 ", + "INVALID_CREDIT_CARD": "必须是有效的信用卡号。 ", + "INVALID_DATE_EURO": "必须是有效的日期格式 (dd-mm-yyyy) 或 (dd/mm/yyyy)。 ", + "INVALID_DATE_EURO_BETWEEN": "需要在{0}和{1}之间的有效日期格式 (dd-mm-yyyy) 或 (dd/mm/yyyy)。 ", + "INVALID_DATE_EURO_MAX": "需要是有效的日期格式 (dd-mm-yyyy) 或 (dd/mm/yyyy), 等于或低于 {0}。 ", + "INVALID_DATE_EURO_MIN": "需要是有效的日期格式 (dd-mm-yyyy) 或 (dd/mm/yyyy), 等于或高于 {0}。 ", + "INVALID_DATE_EURO_LONG": "必须是有效的日期格式 (dd-mm-yyyy) 或 (dd/mm/yyyy)。 ", + "INVALID_DATE_EURO_LONG_BETWEEN": "需要在{0}和{1}之间的有效日期格式 (dd-mm-yyyy) 或 (dd/mm/yyyy)。 ", + "INVALID_DATE_EURO_LONG_MAX": "需要是有效的日期格式 (dd-mm-yyyy) 或 (dd/mm/yyyy), 等于或低于 {0}。 ", + "INVALID_DATE_EURO_LONG_MIN": "需要是有效的日期格式 (dd-mm-yyyy) 或 (dd/mm/yyyy), 等于或高于 {0}。 ", + "INVALID_DATE_EURO_SHORT": "必须是有效的日期格式 (dd-mm-yy) 或 (dd/mm/yy)。 ", + "INVALID_DATE_EURO_SHORT_BETWEEN": "需要在{0}和{1}之间的有效日期格式 (dd-mm-yy) 或 (dd/mm/yy)。 ", + "INVALID_DATE_EURO_SHORT_MAX": "需要是有效的日期格式 (dd-mm-yy) 或 (dd/mm/yy), 等于或低于 {0}。 ", + "INVALID_DATE_EURO_SHORT_MIN": "需要是有效的日期格式 (dd-mm-yy) 或 (dd/mm/yy), 等于或高于 {0}。 ", + "INVALID_DATE_ISO": "必须是有效的日期格式 (yyyy-mm-dd)。 ", + "INVALID_DATE_ISO_BETWEEN": "需要在{0}和{1}之间的有效日期格式 (yyyy-mm-dd)。 ", + "INVALID_DATE_ISO_MAX": "需要是有效的日期格式 (yyyy-mm-dd), 等于或低于 {0}。 ", + "INVALID_DATE_ISO_MIN": "需要是有效的日期格式 (yyyy-mm-dd), 等于或高于 {0}。 ", + "INVALID_DATE_US": "必须是有效的日期格式 (mm/dd/yyyy) 或 (mm-dd-yyyy)。 ", + "INVALID_DATE_US_BETWEEN": "需要在{0}和{1}之间的有效日期格式 (mm/dd/yyyy) 或 (mm-dd-yyyy)。 ", + "INVALID_DATE_US_MAX": "需要是有效的日期格式 (mm/dd/yyyy) 或 (mm-dd-yyyy), 等于或低于 {0}。 ", + "INVALID_DATE_US_MIN": "需要是有效的日期格式 (mm/dd/yyyy) 或 (mm-dd-yyyy), 等于或高于 {0}。 ", + "INVALID_DATE_US_LONG": "必须是有效的日期格式 (mm/dd/yyyy) 或 (mm-dd-yyyy)。 ", + "INVALID_DATE_US_LONG_BETWEEN": "需要在{0}和{1}之间的有效日期格式 (mm/dd/yyyy) 或 (mm-dd-yyyy)。 ", + "INVALID_DATE_US_LONG_MAX": "需要是有效的日期格式(mm / dd / yy)OR(mm-dd-yy),等于或低于{0}。 ", + "INVALID_DATE_US_LONG_MIN": "需要是有效的日期格式(mm / dd / yy)或(mm-dd-yy),等于或低于{0}。 ", + "INVALID_DATE_US_SHORT": "必须是有效的日期格式 (mm/dd/yy) 或 (mm-dd-yy)。 ", + "INVALID_DATE_US_SHORT_BETWEEN": "需要在{0}和{1}之间的有效日期格式 (mm/dd/yy) 或 (mm-dd-yy)。 ", + "INVALID_DATE_US_SHORT_MAX": "需要是有效的日期格式 (mm/dd/yy) 或 (mm-dd-yy), 等于或低于 {0}。 ", + "INVALID_DATE_US_SHORT_MIN": "需要是有效的日期格式 (mm/dd/yy) 或 (mm-dd-yy), 等于或低于 {0}。 ", + "INVALID_DIGITS": "必须是{0}位数。 ", + "INVALID_DIGITS_BETWEEN": "必须介于{0}到{1}位数之间。 ", + "INVALID_EMAIL": "必须是一个有效的电子邮箱地址。 ", + "INVALID_EXACT_LEN": "必须有{0}个字符的长度。 ", + "INVALID_EXACT_NUM": "“必须完全是{0}。 ", + "INVALID_FLOAT": "可能只包含一个正的浮点值(不包括整数)。 ", + "INVALID_FLOAT_SIGNED": "可能只包含正值或负值浮点值(不包括整数)。 ", + "INVALID_IBAN": "必须是有效的IBAN。 ", + "INVALID_IN_LIST": "必须是这个列表中的选择:({0})。 ", + "INVALID_INPUT_DIFFERENT": "字段必须与指定字段[{1}]不同。 ", + "INVALID_INPUT_MATCH": "确认字段与指定字段[{1}]不匹配。 ", + "INVALID_INTEGER": "必须是正整数。 ", + "INVALID_INTEGER_SIGNED": "必须是正整数或负整数。 ", + "INVALID_IPV4": "必须是有效的IP(IPV4)。 ", + "INVALID_IPV6": "必须是有效的IP(IPV6)。 ", + "INVALID_IPV6_HEX": "必须是有效的IP(IPV6 Hex)。 ", + "INVALID_KEY_CHAR": "在”数字“类型的字段上输入的键盘无效。 ", + "INVALID_MAX_CHAR": "不能超过{0}个字符。 ", + "INVALID_MAX_NUM": "需要是数值,等于或低于{0}。 ", + "INVALID_MIN_CHAR": "必须至少{0}个字符。 ", + "INVALID_MIN_NUM": "需要是数值,等于或高于{0}。 ", + "INVALID_NOT_IN_LIST": "必须是这个列表之外的选择:({0})。 ", + "INVALID_NUMERIC": "必须是正数。 ", + "INVALID_NUMERIC_SIGNED": "必须是正数或负数。 ", + "INVALID_PATTERN": "必须遵循以下格式:{0}。 ", + "INVALID_PATTERN_DATA": "必须遵循此格式{{data}}。 ", + "INVALID_PHONE_US": "必须是有效的电话号码,必须包含区号。 ", + "INVALID_PHONE_INTERNATIONAL": "必须是有效的国际电话号码。 ", + "INVALID_REQUIRED": "此项是必须的。 ", + "INVALID_URL": "必须是有效的URL。 ", + "INVALID_TIME": "必须是有效的时间格式(hh:mm)或(hh:mm:ss)。 ", + "INVALID_CHECKBOX_SELECTED": "必须选中复选框。 ", + + "AREA1": "TextArea: 字母数字+最小(15)+ 必需", + "ERRORS": "错误", + "CHANGE_LANGUAGE": "改变语言", + "FORM_PREVALIDATED": "表格预先验证", + "INPUT1": "远程验证 - 为有效答案键入'abc' ", + "INPUT2": "数字正数或负数 - 输入类型='数字 - 非数字字符错误 ", + "INPUT3": "浮动数范围(不包括整数) - between_num:x,y OR min_num:x | max_num:y ", + "INPUT4": "多个验证+日期代码的自定义正则表达式(YYWW)", + "INPUT5": "电子邮件", + "INPUT6": "URL", + "INPUT7": "IP (IPV4)", + "INPUT8": "信用卡", + "INPUT9": "间于(2,6)之间的字符", + "INPUT10": "日期标准格式 (yyyy-mm-dd)", + "INPUT11": "美国长日期格式 (mm/dd/yyyy)", + "INPUT12": "时间 (hh:mm OR hh:mm:ss) -- 非必要项", + "INPUT13": "字母横杠空格 + 必需 + 最小(5) 字符 -- 必须使用: validation-error-to=' '", + "INPUT14": "字母数字+必需 - 未禁用", + "INPUT15": "密码", + "INPUT16": "确认密码", + "INPUT17": "不同的密码", + "INPUT18": "字母数字+确切(3)+必需 - 减震(3秒)", + "INPUT19": "标准日期格式 (yyyy-mm-dd) -- 最小条件> = 2001-01-01", + "INPUT20": "美国短日期格式 (mm/dd/yy) -- 在12/01/99和12/31/15之间", + "INPUT21": "在这些词中选择(香蕉,橙子,冰淇淋,酸甜)", + "FIRST_NAME": "名字", + "LAST_NAME": "姓", + "RESET_FORM": "重置表", + "SAVE": "保存", + "SELECT1": "必需(选择) - 验证(模糊)事件", + "SHOW_VALIDATION_SUMMARY": "显示验证摘要" +} \ No newline at end of file From 012585ad9ff5e32945188bfddf0a0a0c8e05df66 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Wed, 7 Jun 2017 22:02:38 -0400 Subject: [PATCH 38/60] Merged #157 to add Simplified Chinese locale Thanks to @wbiz for providing Simplified Chinese locale --- bower.json | 2 +- changelog.txt | 1 + dist/angular-validation.js | 4 ++-- dist/angular-validation.min.js | 4 ++-- package.json | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index c18636e..b46da93 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.21", + "version": "1.5.22", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index 0a4aea3..91ea023 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.22 (2017-06-07) Merged #157 to add Simplified Chinese locale. 1.5.21 (2017-05-14) Fix #151 validation rule "different" disables rule "required". 1.5.20 (2017-04-20) Add an unminified version and Fix #153 bug in validation service. 1.5.19 (2017-04-17) Fix #150 angularValidation.revalidate problems diff --git a/dist/angular-validation.js b/dist/angular-validation.js index 124ef27..b4c22f8 100644 --- a/dist/angular-validation.js +++ b/dist/angular-validation.js @@ -2,9 +2,9 @@ * Angular-Validation Directive and Service (ghiscoding) * http://github.com/ghiscoding/angular-validation * @author: Ghislain B. - * @version: 1.5.21 + * @version: 1.5.22 * @license: MIT - * @build: Sun May 14 2017 23:35:23 GMT-0400 (Eastern Daylight Time) + * @build: Wed Jun 07 2017 22:01:12 GMT-0400 (Eastern Daylight Time) */ /** * Angular-Validation Directive (ghiscoding) diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 45b6cd1..4310a1f 100644 --- a/dist/angular-validation.min.js +++ b/dist/angular-validation.min.js @@ -2,9 +2,9 @@ * Angular-Validation Directive and Service (ghiscoding) * http://github.com/ghiscoding/angular-validation * @author: Ghislain B. - * @version: 1.5.21 + * @version: 1.5.22 * @license: MIT - * @build: Sun May 14 2017 23:35:23 GMT-0400 (Eastern Daylight Time) + * @build: Wed Jun 07 2017 22:01:12 GMT-0400 (Eastern Daylight Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(A){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&$.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&$.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,A=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){var e=""===a||("boolean"==typeof a?a:"undefined"!=typeof a&&n.$eval(a));e===!0?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue,n=$.getFormElementByName(l.$name);if(n&&n.hasOwnProperty("isValidationCancelled")){var t=o(i);w&&$.runValidationCallbackOnPromise(t,w)}else l.$setValidity("validation",!0)}})}}}]); angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=E(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var l=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",s={field:n,friendlyName:l,message:t,formName:i?i.$name:null};o>=0?Q[o]=s:Q.push(s)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs&&K.controllerAs[u]?K.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;p&&(p.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",l=i.match(new RegExp("^/(.*?)/([gimy]*)$")),s=new RegExp(l[1],l[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:s},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function l(e){return e?A(z,"formName",e):z}function s(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=E(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=E(n,"field",e);if(i>=0&&n.splice(i,1),i=E(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var l=t&&t.translate?a.instant(e):e;l=l.trim();var s=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+s)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(l):n.after('
'+l+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,l=!0,s=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=l+(n&&n.params?String.format(a,n.params):a):p.message+=l+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,s,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=l+o:p.message+=l+o,O(i,e,p.message,s,t)})}(m,l,r)),l&&u++,i.validRequireHowMany==u&&l){s=!0;break}}return l&&(n(i,""),i.updateErrorMsg("",{isValid:l})),m&&(m.isValid=s,s&&(m.message="")),s}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),l=t&&t.friendlyName?a.instant(t.friendlyName):"",s={fieldName:i,friendlyName:l,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=E(z,"fieldName",e.attr("name"));return u>=0?z[u]=s:z.push(s),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=s.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[s]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],l=n[1],s=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,l-1,s,u,p,d)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,l=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var s=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=M(t.condition[0],l,s),d=M(t.condition[1],l,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=M(t.condition,l,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var l=!0,s="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)l=!!d;else{if("object"!=typeof d)throw u;l=!!d.isValid}if(l===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw s;O(r,n,e,!1,i)})):l===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return l}function H(e,t,r,n){var i=!0,l=t.params[0],s=r.scope.$eval(l),u=angular.element(document.querySelector('[name="'+l+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(M(t.condition,e,s)&&!!e),u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(l,function(i,o){var l=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(M(t.condition,e,s)&&!!e);if(i!==o){if(l)O(r,m,"",!0,!0);else{m.isValid=!1;var u=p.message;p.altText&&p.altText.length>0&&(u=p.altText.replace("alt=","")),a(u).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,l,!0)})}d.$setValidity("validation",l)}},!0),i}function I(e,t,a,r,n,i){var o=!0,l="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",s="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();d&&"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw s;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw s;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw l;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled,o=r.elm.prop("disabled"),l=""===o||("boolean"==typeof o?o:"undefined"!=typeof o&&r.scope.$eval(o)),s=""===i||("boolean"==typeof i?i:"undefined"!=typeof i&&r.scope.$eval(i));if(l||s)n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var u=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&u.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=l,X.prototype.getGlobalOptions=s,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); diff --git a/package.json b/package.json index 08ede07..895d399 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.21", + "version": "1.5.22", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": "dist/angular-validation.min", From b6c3799f23228a603046f242e63e256fda3ec2a5 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Wed, 7 Jun 2017 22:07:57 -0400 Subject: [PATCH 39/60] typo --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 58c3ce7..637c08d 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ # Angular Validation (Directive / Service) -`Version: 1.5.21` +`Version: 1.5.22` ### Forms Validation with Angular made easy! ##### (Concept comes from the amazing Laravel) From 6df1c01e19909ec20477d19ff7accf5027667ed9 Mon Sep 17 00:00:00 2001 From: Norbert Csaba Herczeg Date: Wed, 16 Aug 2017 19:19:01 +0200 Subject: [PATCH 40/60] fix reference error The "parentForm" variable is not initialized therefore leads to: ``` ReferenceError: parentForm is not defined ``` --- src/validation-common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validation-common.js b/src/validation-common.js index 8b83b95..d17fd6c 100644 --- a/src/validation-common.js +++ b/src/validation-common.js @@ -816,7 +816,7 @@ angular var formName = (!!formObj) ? formObj.getAttribute("name") : null; if (!!formObj && !!formName) { - parentForm = (!!_globalOptions && !!_globalOptions.controllerAs && formName.indexOf('.') >= 0) + var parentForm = (!!_globalOptions && !!_globalOptions.controllerAs && formName.indexOf('.') >= 0) ? objectFindById(self.scope, formName, '.') : self.scope[formName]; From 26281c21aa994161f0f14894e0d53f5b8ef4921e Mon Sep 17 00:00:00 2001 From: Norbert Csaba Herczeg Date: Wed, 16 Aug 2017 19:46:19 +0200 Subject: [PATCH 41/60] fix Cannot read property 'indexOf' of undefined The `.rules` property could be an empty string in which case the code dies because it uses `self.validatorAttrs.validation` which could be undefined, therefore the `.indexOf` check fails. This fixes TypeError: Cannot read property 'indexOf' of undefined. --- src/validation-common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validation-common.js b/src/validation-common.js index 8b83b95..bb818af 100644 --- a/src/validation-common.js +++ b/src/validation-common.js @@ -178,7 +178,7 @@ angular self = analyzeElementAttributes(self); // get the rules(or validation), inside directive it's named (validation), inside service(rules) - var rules = self.validatorAttrs.rules || self.validatorAttrs.validation; + var rules = self.validatorAttrs.hasOwnProperty('rules') ? self.validatorAttrs.rules : self.validatorAttrs.validation; // We first need to see if the validation holds a custom user regex, if it does then deal with it first // So why deal with it separately? Because a Regex might hold pipe '|' and so we don't want to mix it with our regular validation pipe From 68e0e172806c2e6745ebd9b4b9327afcd03cac28 Mon Sep 17 00:00:00 2001 From: Norbert Csaba Herczeg Date: Wed, 16 Aug 2017 19:52:10 +0200 Subject: [PATCH 42/60] even better failsafe --- src/validation-common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validation-common.js b/src/validation-common.js index bb818af..a5d2657 100644 --- a/src/validation-common.js +++ b/src/validation-common.js @@ -178,7 +178,7 @@ angular self = analyzeElementAttributes(self); // get the rules(or validation), inside directive it's named (validation), inside service(rules) - var rules = self.validatorAttrs.hasOwnProperty('rules') ? self.validatorAttrs.rules : self.validatorAttrs.validation; + var rules = self.validatorAttrs.rules || self.validatorAttrs.validation || ''; // We first need to see if the validation holds a custom user regex, if it does then deal with it first // So why deal with it separately? Because a Regex might hold pipe '|' and so we don't want to mix it with our regular validation pipe From c7114fc6acfb606eb4049843afbda14ddf95b18b Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Thu, 17 Aug 2017 00:36:41 -0400 Subject: [PATCH 43/60] merged PR #162 and PR #163 --- bower.json | 2 +- dist/angular-validation.js | 8 ++++---- dist/angular-validation.min.js | 6 +++--- package.json | 2 +- protractor/badInput_spec.js | 6 ++---- readme.md | 2 +- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/bower.json b/bower.json index b46da93..e98e793 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.22", + "version": "1.5.23", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/dist/angular-validation.js b/dist/angular-validation.js index b4c22f8..870a1ae 100644 --- a/dist/angular-validation.js +++ b/dist/angular-validation.js @@ -2,9 +2,9 @@ * Angular-Validation Directive and Service (ghiscoding) * http://github.com/ghiscoding/angular-validation * @author: Ghislain B. - * @version: 1.5.22 + * @version: 1.5.23 * @license: MIT - * @build: Wed Jun 07 2017 22:01:12 GMT-0400 (Eastern Daylight Time) + * @build: Thu Aug 17 2017 00:34:56 GMT-0400 (Eastern Daylight Time) */ /** * Angular-Validation Directive (ghiscoding) @@ -617,7 +617,7 @@ angular self = analyzeElementAttributes(self); // get the rules(or validation), inside directive it's named (validation), inside service(rules) - var rules = self.validatorAttrs.rules || self.validatorAttrs.validation; + var rules = self.validatorAttrs.rules || self.validatorAttrs.validation || ''; // We first need to see if the validation holds a custom user regex, if it does then deal with it first // So why deal with it separately? Because a Regex might hold pipe '|' and so we don't want to mix it with our regular validation pipe @@ -1255,7 +1255,7 @@ angular var formName = (!!formObj) ? formObj.getAttribute("name") : null; if (!!formObj && !!formName) { - parentForm = (!!_globalOptions && !!_globalOptions.controllerAs && formName.indexOf('.') >= 0) + var parentForm = (!!_globalOptions && !!_globalOptions.controllerAs && formName.indexOf('.') >= 0) ? objectFindById(self.scope, formName, '.') : self.scope[formName]; diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 4310a1f..fae0d3d 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.5.22 + * @version: 1.5.23 * @license: MIT - * @build: Wed Jun 07 2017 22:01:12 GMT-0400 (Eastern Daylight Time) + * @build: Thu Aug 17 2017 00:34:56 GMT-0400 (Eastern Daylight Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(A){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&$.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&$.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,A=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){var e=""===a||("boolean"==typeof a?a:"undefined"!=typeof a&&n.$eval(a));e===!0?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue,n=$.getFormElementByName(l.$name);if(n&&n.hasOwnProperty("isValidationCancelled")){var t=o(i);w&&$.runValidationCallbackOnPromise(t,w)}else l.$setValidity("validation",!0)}})}}}]); -angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=E(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var l=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",s={field:n,friendlyName:l,message:t,formName:i?i.$name:null};o>=0?Q[o]=s:Q.push(s)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs&&K.controllerAs[u]?K.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;p&&(p.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",l=i.match(new RegExp("^/(.*?)/([gimy]*)$")),s=new RegExp(l[1],l[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:s},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function l(e){return e?A(z,"formName",e):z}function s(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=E(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=E(n,"field",e);if(i>=0&&n.splice(i,1),i=E(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var l=t&&t.translate?a.instant(e):e;l=l.trim();var s=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+s)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(l):n.after('
'+l+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,l=!0,s=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=l+(n&&n.params?String.format(a,n.params):a):p.message+=l+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,s,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=l+o:p.message+=l+o,O(i,e,p.message,s,t)})}(m,l,r)),l&&u++,i.validRequireHowMany==u&&l){s=!0;break}}return l&&(n(i,""),i.updateErrorMsg("",{isValid:l})),m&&(m.isValid=s,s&&(m.message="")),s}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),l=t&&t.friendlyName?a.instant(t.friendlyName):"",s={fieldName:i,friendlyName:l,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=E(z,"fieldName",e.attr("name"));return u>=0?z[u]=s:z.push(s),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=s.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[s]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],l=n[1],s=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,l-1,s,u,p,d)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,l=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var s=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=M(t.condition[0],l,s),d=M(t.condition[1],l,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=M(t.condition,l,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var l=!0,s="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)l=!!d;else{if("object"!=typeof d)throw u;l=!!d.isValid}if(l===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw s;O(r,n,e,!1,i)})):l===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return l}function H(e,t,r,n){var i=!0,l=t.params[0],s=r.scope.$eval(l),u=angular.element(document.querySelector('[name="'+l+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(M(t.condition,e,s)&&!!e),u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(l,function(i,o){var l=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(M(t.condition,e,s)&&!!e);if(i!==o){if(l)O(r,m,"",!0,!0);else{m.isValid=!1;var u=p.message;p.altText&&p.altText.length>0&&(u=p.altText.replace("alt=","")),a(u).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,l,!0)})}d.$setValidity("validation",l)}},!0),i}function I(e,t,a,r,n,i){var o=!0,l="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",s="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();d&&"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw s;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw s;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw l;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled,o=r.elm.prop("disabled"),l=""===o||("boolean"==typeof o?o:"undefined"!=typeof o&&r.scope.$eval(o)),s=""===i||("boolean"==typeof i?i:"undefined"!=typeof i&&r.scope.$eval(i));if(l||s)n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var u=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&u.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=l,X.prototype.getGlobalOptions=s,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); +angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=E(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var l=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",s={field:n,friendlyName:l,message:t,formName:i?i.$name:null};o>=0?Q[o]=s:Q.push(s)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs&&K.controllerAs[u]?K.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;p&&(p.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation||"";if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",l=i.match(new RegExp("^/(.*?)/([gimy]*)$")),s=new RegExp(l[1],l[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:s},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function l(e){return e?A(z,"formName",e):z}function s(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=E(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=E(n,"field",e);if(i>=0&&n.splice(i,1),i=E(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var l=t&&t.translate?a.instant(e):e;l=l.trim();var s=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+s)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(l):n.after('
'+l+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,l=!0,s=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=l+(n&&n.params?String.format(a,n.params):a):p.message+=l+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,s,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=l+o:p.message+=l+o,O(i,e,p.message,s,t)})}(m,l,r)),l&&u++,i.validRequireHowMany==u&&l){s=!0;break}}return l&&(n(i,""),i.updateErrorMsg("",{isValid:l})),m&&(m.isValid=s,s&&(m.message="")),s}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),l=t&&t.friendlyName?a.instant(t.friendlyName):"",s={fieldName:i,friendlyName:l,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=E(z,"fieldName",e.attr("name"));return u>=0?z[u]=s:z.push(s),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a];if(r)return"undefined"==typeof r.$name&&(r.$name=a),r}return null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=s.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[s]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],l=n[1],s=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,l-1,s,u,p,d)}function F(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,l=e instanceof Date?e:q(e,o).getTime();if(2==t.params.length){var s=q(t.params[0],o).getTime(),u=q(t.params[1],o).getTime(),p=M(t.condition[0],l,s),d=M(t.condition[1],l,u);r=p&&d}else{var m=q(t.params[0],o).getTime();r=M(t.condition,l,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var l=!0,s="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)l=!!d;else{if("object"!=typeof d)throw u;l=!!d.isValid}if(l===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw s;O(r,n,e,!1,i)})):l===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return l}function H(e,t,r,n){var i=!0,l=t.params[0],s=r.scope.$eval(l),u=angular.element(document.querySelector('[name="'+l+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(M(t.condition,e,s)&&!!e),u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(l,function(i,o){var l=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(M(t.condition,e,s)&&!!e);if(i!==o){if(l)O(r,m,"",!0,!0);else{m.isValid=!1;var u=p.message;p.altText&&p.altText.length>0&&(u=p.altText.replace("alt=","")),a(u).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,l,!0)})}d.$setValidity("validation",l)}},!0),i}function I(e,t,a,r,n,i){var o=!0,l="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",s="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();d&&"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw s;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw s;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw l;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled,o=r.elm.prop("disabled"),l=""===o||("boolean"==typeof o?o:"undefined"!=typeof o&&r.scope.$eval(o)),s=""===i||("boolean"==typeof i?i:"undefined"!=typeof i&&r.scope.$eval(i));if(l||s)n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var u=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&u.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){F(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){F(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=l,X.prototype.getGlobalOptions=s,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return g=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,$=n.validationAttrs.hasOwnProperty("validateOnEmpty")?n.commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);g&&n.commonObj.runValidationCallbackOnPromise(t,g)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e,o){var t=this,a="",n=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var i=0,l=e.$validationSummary.length;i0&&("function"!=typeof m.ctrl.$setTouched||o||m.ctrl.$setTouched(),t.commonObj.updateErrorMsg(e.$validationSummary[i].message,{isSubmitted:!o,isValid:m.isValid,obj:m}))}return n}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a Date: Thu, 17 Aug 2017 00:42:38 -0400 Subject: [PATCH 44/60] update changelog --- changelog.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 91ea023..568afa4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ Angular-Validation change logs -1.5.22 (2017-06-07) Merged #157 to add Simplified Chinese locale. +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". 1.5.20 (2017-04-20) Add an unminified version and Fix #153 bug in validation service. 1.5.19 (2017-04-17) Fix #150 angularValidation.revalidate problems From 2da692349ffaffca5b66ef7708659f281aa47741 Mon Sep 17 00:00:00 2001 From: Ghislain Beaulac Date: Fri, 1 Sep 2017 23:47:18 -0400 Subject: [PATCH 45/60] fix #160 validate on empty validation-service --- bower.json | 2 +- changelog.txt | 1 + dist/angular-validation.js | 20 ++++++++++---------- dist/angular-validation.min.js | 6 +++--- package.json | 2 +- readme.md | 2 +- src/validation-service.js | 16 ++++++++-------- 7 files changed, 25 insertions(+), 24 deletions(-) diff --git a/bower.json b/bower.json index e98e793..63c6b85 100644 --- a/bower.json +++ b/bower.json @@ -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": [ diff --git a/changelog.txt b/changelog.txt index 568afa4..18e80be 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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". diff --git a/dist/angular-validation.js b/dist/angular-validation.js index 870a1ae..f449853 100644 --- a/dist/angular-validation.js +++ b/dist/angular-validation.js @@ -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) @@ -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 @@ -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); diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index fae0d3d..a314179 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.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.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(A){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&$.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&$.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,A=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){var e=""===a||("boolean"==typeof a?a:"undefined"!=typeof a&&n.$eval(a));e===!0?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue,n=$.getFormElementByName(l.$name);if(n&&n.hasOwnProperty("isValidationCancelled")){var t=o(i);w&&$.runValidationCallbackOnPromise(t,w)}else l.$setValidity("validation",!0)}})}}}]); angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=E(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var l=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",s={field:n,friendlyName:l,message:t,formName:i?i.$name:null};o>=0?Q[o]=s:Q.push(s)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs&&K.controllerAs[u]?K.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;p&&(p.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation||"";if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",l=i.match(new RegExp("^/(.*?)/([gimy]*)$")),s=new RegExp(l[1],l[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:s},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function l(e){return e?A(z,"formName",e):z}function s(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=E(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=E(n,"field",e);if(i>=0&&n.splice(i,1),i=E(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var l=t&&t.translate?a.instant(e):e;l=l.trim();var s=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+s)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(l):n.after('
'+l+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,l=!0,s=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=l+(n&&n.params?String.format(a,n.params):a):p.message+=l+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,s,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=l+o:p.message+=l+o,O(i,e,p.message,s,t)})}(m,l,r)),l&&u++,i.validRequireHowMany==u&&l){s=!0;break}}return l&&(n(i,""),i.updateErrorMsg("",{isValid:l})),m&&(m.isValid=s,s&&(m.message="")),s}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),l=t&&t.friendlyName?a.instant(t.friendlyName):"",s={fieldName:i,friendlyName:l,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=E(z,"fieldName",e.attr("name"));return u>=0?z[u]=s:z.push(s),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a];if(r)return"undefined"==typeof r.$name&&(r.$name=a),r}return null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=s.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[s]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],l=n[1],s=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,l-1,s,u,p,d)}function F(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,l=e instanceof Date?e:q(e,o).getTime();if(2==t.params.length){var s=q(t.params[0],o).getTime(),u=q(t.params[1],o).getTime(),p=M(t.condition[0],l,s),d=M(t.condition[1],l,u);r=p&&d}else{var m=q(t.params[0],o).getTime();r=M(t.condition,l,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var l=!0,s="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)l=!!d;else{if("object"!=typeof d)throw u;l=!!d.isValid}if(l===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw s;O(r,n,e,!1,i)})):l===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return l}function H(e,t,r,n){var i=!0,l=t.params[0],s=r.scope.$eval(l),u=angular.element(document.querySelector('[name="'+l+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(M(t.condition,e,s)&&!!e),u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(l,function(i,o){var l=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(M(t.condition,e,s)&&!!e);if(i!==o){if(l)O(r,m,"",!0,!0);else{m.isValid=!1;var u=p.message;p.altText&&p.altText.length>0&&(u=p.altText.replace("alt=","")),a(u).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,l,!0)})}d.$setValidity("validation",l)}},!0),i}function I(e,t,a,r,n,i){var o=!0,l="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",s="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();d&&"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw s;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw s;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw l;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled,o=r.elm.prop("disabled"),l=""===o||("boolean"==typeof o?o:"undefined"!=typeof o&&r.scope.$eval(o)),s=""===i||("boolean"==typeof i?i:"undefined"!=typeof i&&r.scope.$eval(i));if(l||s)n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var u=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&u.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){F(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){F(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=l,X.prototype.getGlobalOptions=s,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; -angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return g=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,$=n.validationAttrs.hasOwnProperty("validateOnEmpty")?n.commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);g&&n.commonObj.runValidationCallbackOnPromise(t,g)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e,o){var t=this,a="",n=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var i=0,l=e.$validationSummary.length;i0&&("function"!=typeof m.ctrl.$setTouched||o||m.ctrl.$setTouched(),t.commonObj.updateErrorMsg(e.$validationSummary[i].message,{isSubmitted:!o,isValid:m.isValid,obj:m}))}return n}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a0&&("function"!=typeof m.ctrl.$setTouched||o||m.ctrl.$setTouched(),t.commonObj.updateErrorMsg(e.$validationSummary[i].message,{isSubmitted:!o,isValid:m.isValid,obj:m}))}return n}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a Date: Mon, 29 Oct 2018 12:30:22 -0400 Subject: [PATCH 46/60] add Chinese locale translation "cn.json" --- bower.json | 2 +- changelog.txt | 1 + locales/validation/cn.json | 104 +++++++++++++++++++++++++++++++++++++ package.json | 2 +- 4 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 locales/validation/cn.json diff --git a/bower.json b/bower.json index 63c6b85..cca1cbd 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.24", + "version": "1.5.25", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index 18e80be..fddec95 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.25 (2018-10-29) Add Chinese locale "cn.json" in the locales folder. 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. diff --git a/locales/validation/cn.json b/locales/validation/cn.json new file mode 100644 index 0000000..0833f9d --- /dev/null +++ b/locales/validation/cn.json @@ -0,0 +1,104 @@ +{ + "INVALID_ACCEPTED": "必须接受", + "INVALID_ALPHA":"只能带字母", + "INVALID_ALPHA_SPACE":"只能帶字母或空格", + "INVALID_ALPHA_NUM":"只能帶字母或数字", + "INVALID_ALPHA_NUM_SPACE":"只能带字母或数字或空格", + "INVALID_ALPHA_DASH":"只能带字母或数字或破折号", + "INVALID_ALPHA_DASH_SPACE":"只能带字母或数字或空格或破折号", + "INVALID_BETWEEN_CHAR":"文本必须介于{0}和{1}之间", + "INVALID_BETWEEN_NUM":"需要一个数值在{0}和{1}之间", + "INVALID_BOOLEAN":"只能带真值或假值", + "INVALID_CREDIT_CARD":"必须是有效的信用卡号码", + "INVALID_DATE_EURO":"必须是一个有效的日期格式(dd-mm-yyyy)或(dd/mm/yyyy)", + "INVALID_DATE_EURO_BETWEEN":"需要一个有效的日期格式(dd-mm-yyyy)或(dd/mm/yyyy)在{0}和{1}之间", + "INVALID_DATE_EURO_MAX":"需要一个有效的日期格式(dd-mm-yyyy)或(dd/mm/yyyy),等于或低于{0}", + "INVALID_DATE_EURO_MIN":"需要一个有效的日期格式(dd-mm-yyyy)或(dd/mm/yyyy),等于或高于{0}", + "INVALID_DATE_EURO_LONG":"必须是一个有效的日期格式(dd-mm-yyyy)或(dd/mm/yyyy)", + "INVALID_DATE_EURO_LONG_BETWEEN":"需要一个有效的日期格式(dd-mm-yyyy)或(dd/mm/yyyy)在{0}和{1}之间", + "INVALID_DATE_EURO_LONG_MAX":"需要一个有效的日期格式(dd-mm-yyyy)或(dd/mm/yyyy),等于或低于{0}", + "INVALID_DATE_EURO_LONG_MIN":"需要一个有效的日期格式(dd-mm-yyyy)或(dd/mm/yyyy),等于或高于{0}", + "INVALID_DATE_EURO_SHORT":"必须是一个有效的日期格式(dd-mm-yy)或(dd/mm/yy)", + "INVALID_DATE_EURO_SHORT_BETWEEN":"需要一个有效的日期格式(dd-mm-yy)或(dd/mm/yy)在{0}和{1}之间", + "INVALID_DATE_EURO_SHORT_MAX":"需要一个有效的日期格式(dd-mm-yy)或(dd/mm/yy),等于或低于{0}", + "INVALID_DATE_EURO_SHORT_MIN":"需要一个有效的日期格式(dd-mm-yy)或(dd/mm/yy),等于或高于{0}", + "INVALID_DATE_ISO":"必须是一个有效的日期格式(yyyy-mm-dd)", + "INVALID_DATE_ISO_BETWEEN":"需要一个有效的日期格式(yyyy-mm-dd)在{0}和{1}之间", + "INVALID_DATE_ISO_MAX":"需要一个有效的日期格式(yyyy-mm-dd),等于或低于{0}", + "INVALID_DATE_ISO_MIN":"需要一个有效的日期格式(yyyy-mm-dd),等于或高于{0}", + "INVALID_DATE_US":"必须是一个有效的日期格式(mm/dd/yyyy)或(mm-dd-yyyy)", + "INVALID_DATE_US_BETWEEN":"需要一个有效的日期格式(mm/dd/yyyy)或(mm-dd-yyyy)在{0}和{1}之间", + "INVALID_DATE_US_MAX":"需要一个有效的日期格式(mm/dd/yyyy)或(mm-dd-yyyy),等于或低于{0}", + "INVALID_DATE_US_MIN":"需要一个有效的日期格式(mm/dd/yyyy)或(mm-dd-yyyy),等于或高于{0}", + "INVALID_DATE_US_LONG":"必须是一个有效的日期格式(mm/dd/yyyy)或(mm-dd-yyyy)", + "INVALID_DATE_US_LONG_BETWEEN":"需要一个有效的日期格式(mm/dd/yyyy)或(mm-dd-yyyy)在{0}和{1}之间", + "INVALID_DATE_US_LONG_MAX":"需要一个有效的日期格式(mm/dd/yyyy)或(mm-dd-yyyy),等于或低于{0}", + "INVALID_DATE_US_LONG_MIN":"需要一个有效的日期格式(mm/dd/yyyy)或(mm-dd-yyyy),等于或高于{0}", + "INVALID_DATE_US_SHORT":"必须是一个有效的日期格式(mm/dd/yy)或(mm-dd-yy)", + "INVALID_DATE_US_SHORT_BETWEEN":"需要一个有效的日期格式(mm/dd/yy)或(mm-dd-yy)在{0}和{1}之间", + "INVALID_DATE_US_SHORT_MAX":"需要一个有效的日期格式(mm/dd/yy)或(mm-dd-yy),等于或低于{0}", + "INVALID_DATE_US_SHORT_MIN":"需要一个有效的日期格式(mm/dd/yy)或(mm-dd-yy),等于或高于{0}", + "INVALID_DIGITS":"数字必须是{0}", + "INVALID_DIGITS_BETWEEN":"数字必须介于{0}和{1}之间", + "INVALID_EMAIL":"必须是有效的电子邮件地址", + "INVALID_EXACT_LEN":"必须具有确切的字符{0}", + "INVALID_EXACT_NUM":"必须是{0}", + "INVALID_FLOAT":"只能带正浮点值(integer excluded)", + "INVALID_FLOAT_SIGNED":"只能带正或负浮点值(integer excluded)", + "INVALID_IBAN":"必须是一个有效的日期", + "INVALID_IN_LIST":"必须是此列表内的选择:({0})", + "INVALID_INPUT_DIFFERENT":"字段必须与指定字段不同[{1}]", + "INVALID_INPUT_MATCH":"确认字段与指定字段不匹配[{1}]", + "INVALID_INTEGER":"必须是正整数", + "INVALID_INTEGER_SIGNED":"必须是正整数或负整数", + "INVALID_IPV4":"必须是一个有效的IP (IPV4)", + "INVALID_IPV6":"必须是一个有效的IP (IPV6)", + "INVALID_IPV6_HEX":"必须是一个有效的IP (IPV6 Hex)", + "INVALID_KEY_CHAR":"“数字”字段上的键盘输入无效", + "INVALID_MAX_CHAR":"字符可能不大于{0}", + "INVALID_MAX_NUM":"数值需要等于或低于{0}", + "INVALID_MIN_CHAR":"字符必须至少{0}", + "INVALID_MIN_NUM":"数值需要等于或高于{0}", + "INVALID_NOT_IN_LIST":"必须是此列表之外的选择:({0})", + "INVALID_NUMERIC":"必须是正数", + "INVALID_NUMERIC_SIGNED":"必须是正数或负数", + "INVALID_PATTERN":"必须遵循以下格式:{0}", + "INVALID_PATTERN_DATA":"必须遵循此格式{{data}}", + "INVALID_PHONE_US":"必须是有效的电话号码,包括区号", + "INVALID_PHONE_INTERNATIONAL":"必须是有效的国际电话号码", + "INVALID_REQUIRED":"字段是必需的", + "INVALID_URL":"必须是有效网址", + "INVALID_TIME":"必须是一个有效的时间格式 (hh:mm) 或 (hh:mm:ss)", + "INVALID_CHECKBOX_SELECTED":"复选框必须选择", + "AREA1":"文本:数字+最小(15)+要求", + "ERRORS":"错误", + "CHANGE_LANGUAGE":"改变语言", + "FORM_PREVALIDATED":"表单预验证", + "INPUT1":"远程验证-键入一个有效答案的ABC", + "INPUT2":"数正的或负的输入类型=’数字’—非数字字符上的错误", + "INPUT3":"Floating number range (integer excluded) -- between_num:x,y OR min_num:x|max_num:y ", + "INPUT4":"多重验证+自定义正则表达式日期代码(yyww)", + "INPUT5":"电子邮件", + "INPUT6":"统一资源定位地址", + "INPUT7":"IP (IPV4)", + "INPUT8":"信用卡", + "INPUT9":"在(2,6)之间", + "INPUT10":"日期等 (yyyy-mm-dd)", + "INPUT11":"请用详细美式日期 (mm/dd/yyyy)", + "INPUT12":"时间(hh:mm OR hh:mm:ss)--不需要", + "INPUT13":"AlphaDashSpaces + Required + Minimum(5) Characters -- MUST USE: validation-error-to=' '", + "INPUT14":"Alphanumeric + Required -- NG-DISABLED", + "INPUT15":"密码", + "INPUT16":"密码确认", + "INPUT17":"不同的密码", + "INPUT18":"(3)+数字+完全需要消抖(3sec)", + "INPUT19":"日期等(yyyy-mm-dd)--最小条件> = 2001-01-01", + "INPUT20":"请用简短美式日期 (mm/dd/yy) --日期12/01/99和12/31/15之间", + "INPUT21":"在这个列表中选择(banana,orange,ice cream,sweet & sour)", + "FIRST_NAME":"名字", + "LAST_NAME":"姓", + "RESET_FORM":"复位形式", + "SAVE":"保存", + "SELECT1":"要求(select)-验证与(blur)事件", + "SHOW_VALIDATION_SUMMARY":"显示验证总结" +} \ No newline at end of file diff --git a/package.json b/package.json index 43f424b..23ca587 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.24", + "version": "1.5.25", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": "dist/angular-validation.min", From 35e30417d0e51a8fda319865bff27560e360a9bc Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Tue, 30 Oct 2018 19:33:39 -0400 Subject: [PATCH 47/60] add life-support comment in readme --- readme.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index cea1a9a..20e39ef 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,21 @@ # Angular Validation (Directive / Service) -`Version: 1.5.24` +`Version: 1.5.25` + +## Project in Life Support +##### still accepting PR for any bug fix + +This project is now in Life Support since most of us already moved to newer version of Angular. However I do want to point out that if you still use the lib and find a Bug, I certainly still welcome PR (Pull Request) to address bug fixes. So I'm not totally gone but I won't personally invest more time in the lib. Also note that the lib will not be rewritten to support Angular 2+ + +On a totally different note, I'm still very active in the Angular 4+ world (even Aurelia world) and you might be interested in looking at some of my other libraries. +- [Angular-Slickgrid](https://github.com/ghiscoding/Angular-Slickgrid) +- [Angular Markdown Preview Editor](https://github.com/ghiscoding/angular-markdown-editor) + +In the Aurelia world +- [Aurelia-Slickgrid](https://github.com/ghiscoding/aurelia-slickgrid) +- [Aurelia Bootstrap Plugin](https://github.com/ghiscoding/Aurelia-Bootstrap-Plugins) + +--- + ### Forms Validation with Angular made easy! ##### (Concept comes from the amazing Laravel) From 7291142cd0d079b28658e3d6e87ef7332dc4a253 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Tue, 30 Oct 2018 19:34:21 -0400 Subject: [PATCH 48/60] update life-support comment --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 20e39ef..125932c 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ `Version: 1.5.25` ## Project in Life Support -##### still accepting PR for any bug fix +### still accepting PR for any bug fix This project is now in Life Support since most of us already moved to newer version of Angular. However I do want to point out that if you still use the lib and find a Bug, I certainly still welcome PR (Pull Request) to address bug fixes. So I'm not totally gone but I won't personally invest more time in the lib. Also note that the lib will not be rewritten to support Angular 2+ From 1f455c81dfaf1594b0e57ce8191a0da416319f65 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Tue, 30 Oct 2018 19:35:14 -0400 Subject: [PATCH 49/60] update life-support comment --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 125932c..b0c0846 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ `Version: 1.5.25` ## Project in Life Support -### still accepting PR for any bug fix +#### still accepting PR for any bug fix This project is now in Life Support since most of us already moved to newer version of Angular. However I do want to point out that if you still use the lib and find a Bug, I certainly still welcome PR (Pull Request) to address bug fixes. So I'm not totally gone but I won't personally invest more time in the lib. Also note that the lib will not be rewritten to support Angular 2+ From b20b8f2f213e6f39f0f3eafe3e22df902f3db70a Mon Sep 17 00:00:00 2001 From: mgm09a Date: Fri, 9 Nov 2018 11:09:54 -0600 Subject: [PATCH 50/60] Fix for incorrect validation on "required" with a value of 0 Fixes issue #177 --- src/validation-directive.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/validation-directive.js b/src/validation-directive.js index 3bd2dcc..e471632 100644 --- a/src/validation-directive.js +++ b/src/validation-directive.js @@ -179,7 +179,7 @@ } // invalidate field before doing any validation - if(!!value || commonObj.isFieldRequired() || _validateOnEmpty) { + if((value === "" || value === null || typeof value === "undefined") || commonObj.isFieldRequired() || _validateOnEmpty) { ctrl.$setValidity('validation', false); } @@ -403,7 +403,9 @@ /** Re-evaluate the element and revalidate it, also re-attach the onBlur event on the element */ function revalidateAndAttachOnBlur() { // Revalidate the input when enabled (without displaying the error) - var value = ctrl.$modelValue || ''; + var value = ctrl.$modelValue !== null && typeof ctrl.$modelValue !== 'undefined' + ? ctrl.$modelValue + : ''; if(!Array.isArray(value)) { ctrl.$setValidity('validation', commonObj.validate(value, false)); } From b249f4ae4b9bb91b3231f9a07a4aad5642100fdb Mon Sep 17 00:00:00 2001 From: mgm09a Date: Fri, 9 Nov 2018 11:13:42 -0600 Subject: [PATCH 51/60] Update src/validation-directive.js --- src/validation-directive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validation-directive.js b/src/validation-directive.js index e471632..a6f6799 100644 --- a/src/validation-directive.js +++ b/src/validation-directive.js @@ -179,7 +179,7 @@ } // invalidate field before doing any validation - if((value === "" || value === null || typeof value === "undefined") || commonObj.isFieldRequired() || _validateOnEmpty) { + if((value !== "" || value !== null || typeof value !== "undefined") || commonObj.isFieldRequired() || _validateOnEmpty) { ctrl.$setValidity('validation', false); } From 134acccf6891a5e37d019bcced3b8a31f2432be9 Mon Sep 17 00:00:00 2001 From: mgm09a Date: Mon, 12 Nov 2018 08:56:35 -0600 Subject: [PATCH 52/60] Update src/validation-directive.js Fix to properly negate expression. --- src/validation-directive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validation-directive.js b/src/validation-directive.js index a6f6799..49fe9b4 100644 --- a/src/validation-directive.js +++ b/src/validation-directive.js @@ -179,7 +179,7 @@ } // invalidate field before doing any validation - if((value !== "" || value !== null || typeof value !== "undefined") || commonObj.isFieldRequired() || _validateOnEmpty) { + if((value !== "" && value !== null && typeof value !== "undefined") || commonObj.isFieldRequired() || _validateOnEmpty) { ctrl.$setValidity('validation', false); } From cc44b278bf1baba42ff88813c6230bd65d51b2ab Mon Sep 17 00:00:00 2001 From: ghiscoding Date: Tue, 13 Nov 2018 23:26:19 -0500 Subject: [PATCH 53/60] bump version after merge of PR #178 --- .gitignore | 3 +++ .npmignore | 1 + bower.json | 2 +- changelog.txt | 1 + package.json | 2 +- readme.md | 4 ++-- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 06ab436..3ecc873 100644 --- a/.gitignore +++ b/.gitignore @@ -222,5 +222,8 @@ pip-log.txt #Mr Developer .mr.developer.cfg + +# Lock files +package-lock.json yarn-error.log yarn.lock \ No newline at end of file diff --git a/.npmignore b/.npmignore index 9a1941d..124e1e6 100644 --- a/.npmignore +++ b/.npmignore @@ -7,5 +7,6 @@ templates/ app.js gulpfile.js index.html +package-lock.json yarn-error.log yarn.lock \ No newline at end of file diff --git a/bower.json b/bower.json index cca1cbd..c2fb16c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.25", + "version": "1.5.26", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index fddec95..428a65a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.26 (2018-11-13) Merged PR #178 to fix revalidateAndAttachOnBlur method to handle zeroes appropriately 1.5.25 (2018-10-29) Add Chinese locale "cn.json" in the locales folder. 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 diff --git a/package.json b/package.json index 23ca587..7d629e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.25", + "version": "1.5.26", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": "dist/angular-validation.min", diff --git a/readme.md b/readme.md index b0c0846..b5ae5a9 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ # Angular Validation (Directive / Service) -`Version: 1.5.25` +`Version: 1.5.26` ## Project in Life Support #### still accepting PR for any bug fix @@ -7,7 +7,7 @@ This project is now in Life Support since most of us already moved to newer version of Angular. However I do want to point out that if you still use the lib and find a Bug, I certainly still welcome PR (Pull Request) to address bug fixes. So I'm not totally gone but I won't personally invest more time in the lib. Also note that the lib will not be rewritten to support Angular 2+ On a totally different note, I'm still very active in the Angular 4+ world (even Aurelia world) and you might be interested in looking at some of my other libraries. -- [Angular-Slickgrid](https://github.com/ghiscoding/Angular-Slickgrid) +- [Angular-Slickgrid](https://github.com/ghiscoding/Angular-Slickgrid) - [Angular Markdown Preview Editor](https://github.com/ghiscoding/angular-markdown-editor) In the Aurelia world From 5f629e16c1f988d566348ff80b4725f083a0bca6 Mon Sep 17 00:00:00 2001 From: PrashantP25 <49611236+PrashantP25@users.noreply.github.com> Date: Sun, 14 Apr 2019 18:38:52 +0530 Subject: [PATCH 54/60] Update validation-service.js file resolved radio button required field validation when validation are added via addValidator method --- src/validation-service.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/validation-service.js b/src/validation-service.js index d4cb8f0..fa1464f 100644 --- a/src/validation-service.js +++ b/src/validation-service.js @@ -106,7 +106,7 @@ angular self.commonObj.initialize(scope, attrs.elm, attrs, attrs.ctrl); // attempt to validate & run validation callback if user requested it - var validationPromise = attemptToValidate(self, event.target.value, 0); + var validationPromise = attemptToValidate(self, (attrs.ctrl.$modelValue == undefined ? '' : attrs.ctrl.$modelValue), 0); if(!!_validationCallback) { self.commonObj.runValidationCallbackOnPromise(validationPromise, _validationCallback); } @@ -574,7 +574,7 @@ angular attrs.elm.bind('blur', _blurHandler = function(event) { if (!!formElmObj && !formElmObj.isValidationCancelled) { // attempt to validate & run validation callback if user requested it - var validationPromise = attemptToValidate(self, event.target.value, 10); + var validationPromise = attemptToValidate(self, (attrs.ctrl.$modelValue == undefined ? '' : attrs.ctrl.$modelValue), 10); if(!!_validationCallback) { self.commonObj.runValidationCallbackOnPromise(validationPromise, _validationCallback); } @@ -596,4 +596,4 @@ angular }); } -}]); // ValidationService \ No newline at end of file +}]); // ValidationService From f8143cbb6186454eae254a1a435438165954bd8c Mon Sep 17 00:00:00 2001 From: ghiscoding Date: Sun, 14 Apr 2019 21:24:46 -0400 Subject: [PATCH 55/60] fix indentation from last PR --- src/validation-service.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/validation-service.js b/src/validation-service.js index fa1464f..5769eb5 100644 --- a/src/validation-service.js +++ b/src/validation-service.js @@ -106,7 +106,7 @@ angular self.commonObj.initialize(scope, attrs.elm, attrs, attrs.ctrl); // attempt to validate & run validation callback if user requested it - var validationPromise = attemptToValidate(self, (attrs.ctrl.$modelValue == undefined ? '' : attrs.ctrl.$modelValue), 0); + var validationPromise = attemptToValidate(self, (attrs.ctrl.$modelValue == undefined ? '' : attrs.ctrl.$modelValue), 0); if(!!_validationCallback) { self.commonObj.runValidationCallbackOnPromise(validationPromise, _validationCallback); } @@ -574,7 +574,7 @@ angular attrs.elm.bind('blur', _blurHandler = function(event) { if (!!formElmObj && !formElmObj.isValidationCancelled) { // attempt to validate & run validation callback if user requested it - var validationPromise = attemptToValidate(self, (attrs.ctrl.$modelValue == undefined ? '' : attrs.ctrl.$modelValue), 10); + var validationPromise = attemptToValidate(self, (attrs.ctrl.$modelValue == undefined ? '' : attrs.ctrl.$modelValue), 10); if(!!_validationCallback) { self.commonObj.runValidationCallbackOnPromise(validationPromise, _validationCallback); } From 3ca263b3d05c2d62e3ed53c2d2c1ee12c0442d6e Mon Sep 17 00:00:00 2001 From: ghiscoding Date: Sun, 14 Apr 2019 21:27:23 -0400 Subject: [PATCH 56/60] prepare release 1.5.27 --- bower.json | 2 +- changelog.txt | 1 + package.json | 2 +- readme.md | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index c2fb16c..5e3519a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.26", + "version": "1.5.27", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index 428a65a..399cecd 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.27 (2019-04-14) Merged PR #182 to fix Radio button required field validation not working, closes #181 1.5.26 (2018-11-13) Merged PR #178 to fix revalidateAndAttachOnBlur method to handle zeroes appropriately 1.5.25 (2018-10-29) Add Chinese locale "cn.json" in the locales folder. 1.5.24 (2017-09-01) Fix #160, validate on empty not working in angular-service diff --git a/package.json b/package.json index 7d629e9..785536f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.26", + "version": "1.5.27", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": "dist/angular-validation.min", diff --git a/readme.md b/readme.md index b5ae5a9..83be87e 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ # Angular Validation (Directive / Service) -`Version: 1.5.26` +`Version: 1.5.27` ## Project in Life Support #### still accepting PR for any bug fix From 07fa6bf8c4128e52ccaa4337749c5da412e14424 Mon Sep 17 00:00:00 2001 From: ghiscoding Date: Sun, 14 Apr 2019 21:33:32 -0400 Subject: [PATCH 57/60] update readme --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 83be87e..990e932 100644 --- a/readme.md +++ b/readme.md @@ -3,6 +3,7 @@ ## Project in Life Support #### still accepting PR for any bug fix +**Also note that only NPM will updated with new releases when PR get merged** This project is now in Life Support since most of us already moved to newer version of Angular. However I do want to point out that if you still use the lib and find a Bug, I certainly still welcome PR (Pull Request) to address bug fixes. So I'm not totally gone but I won't personally invest more time in the lib. Also note that the lib will not be rewritten to support Angular 2+ From c884bc4030cd923aca60bc42bbfdbd863b9920a8 Mon Sep 17 00:00:00 2001 From: PrashantP25 <49611236+PrashantP25@users.noreply.github.com> Date: Sat, 8 Jun 2019 14:47:24 +0530 Subject: [PATCH 58/60] Update validation-common.js file Update validation-common.js file to add method to remove item from array when values of and object matches --- src/validation-common.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/validation-common.js b/src/validation-common.js index f82ba84..ef55de0 100644 --- a/src/validation-common.js +++ b/src/validation-common.js @@ -66,6 +66,7 @@ angular // list of available published public functions of this object validationCommon.prototype.addToValidationSummary = addToValidationSummary; // add an element to the $validationSummary validationCommon.prototype.arrayFindObject = arrayFindObject; // search an object inside an array of objects + validationCommon.prototype.arrayRemoveObject = arrayRemoveObject; // search an object inside an array of objects and remove it from array validationCommon.prototype.defineValidation = defineValidation; // define our validation object validationCommon.prototype.getFormElementByName = getFormElementByName; // get the form element custom object by it's name validationCommon.prototype.getFormElements = getFormElements; // get the array of form elements (custom objects) @@ -771,6 +772,25 @@ angular return null; } + /** Quick function to remove an object inside an array by it's given field name and value, return and remove the object found or null + * @param Array sourceArray + * @param string searchId: search property id + * @param string searchValue: value to search + * @return object found from source array or null + */ + function arrayRemoveObject(sourceArray, searchId, searchValue) { + if (!!sourceArray) { + for (var i = 0; i < sourceArray.length; i++) { + if (sourceArray[i][searchId] === searchValue) { + var itemToRemove = sourceArray[i]; + sourceArray.splice(i,1); + return itemToRemove; + } + } + } + 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 From 8380c0efb3cbfb264ed9e163b846df335649b2e2 Mon Sep 17 00:00:00 2001 From: PrashantP25 <49611236+PrashantP25@users.noreply.github.com> Date: Sat, 8 Jun 2019 14:52:52 +0530 Subject: [PATCH 59/60] Changes done in 2 methods in validation-service.js changes done in attemptToValidate (line number 339) method and removeWatcherAndErrorMessage (line number 494) method --- src/validation-service.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/validation-service.js b/src/validation-service.js index 5769eb5..7ce53a8 100644 --- a/src/validation-service.js +++ b/src/validation-service.js @@ -334,9 +334,12 @@ angular // pre-validate without any events just to pre-fill our validationSummary with all field errors // passing false as 2nd argument for not showing any errors on screen self.commonObj.validate(value, false); - + + // check field level setting for validateOnEmpty + var isFieldValidateOnEmpty = (self.commonObj.validatorAttrs && self.commonObj.validatorAttrs.validateOnEmpty); + // if field is not required and his value is empty, cancel validation and exit out - if(!self.commonObj.isFieldRequired() && !_validateOnEmpty && (value === "" || value === null || typeof value === "undefined")) { + if(!self.commonObj.isFieldRequired() && !(_validateOnEmpty || isFieldValidateOnEmpty) && (value === "" || value === null || typeof value === "undefined")) { cancelValidation(self, formElmObj); deferred.resolve({ isFieldValid: true, formElmObj: formElmObj, value: value }); return deferred.promise; @@ -491,7 +494,7 @@ angular var foundWatcher = self.commonObj.arrayFindObject(_watchers, 'elmName', formElmObj.fieldName); if(!!foundWatcher) { foundWatcher.watcherHandler(); // deregister the watch by calling his handler - _watchers.shift(); + self.commonObj.arrayRemoveObject(_watchers, 'elmName', formElmObj.fieldName); } // make the validation cancelled so it won't get called anymore in the blur eventHandler From 3a1c83aac30ccb2f3631c9bf131c63223a82443d Mon Sep 17 00:00:00 2001 From: ghiscoding Date: Thu, 20 Jun 2019 21:20:36 -0400 Subject: [PATCH 60/60] prepare release 1.5.28 --- bower.json | 2 +- changelog.txt | 1 + dist/angular-validation.js | 45 ++++++++++++++++++++++++++-------- dist/angular-validation.min.js | 10 ++++---- package.json | 2 +- readme.md | 2 +- 6 files changed, 44 insertions(+), 18 deletions(-) diff --git a/bower.json b/bower.json index 5e3519a..2a95ccc 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.27", + "version": "1.5.28", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index 399cecd..4bc5352 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.28 (2019-06-20) Merged PR #183, #184 fixes #185 Issue while de-registering a watcher and field level validateOnEmpty 1.5.27 (2019-04-14) Merged PR #182 to fix Radio button required field validation not working, closes #181 1.5.26 (2018-11-13) Merged PR #178 to fix revalidateAndAttachOnBlur method to handle zeroes appropriately 1.5.25 (2018-10-29) Add Chinese locale "cn.json" in the locales folder. diff --git a/dist/angular-validation.js b/dist/angular-validation.js index f449853..b9139bc 100644 --- a/dist/angular-validation.js +++ b/dist/angular-validation.js @@ -2,9 +2,9 @@ * Angular-Validation Directive and Service (ghiscoding) * http://github.com/ghiscoding/angular-validation * @author: Ghislain B. - * @version: 1.5.24 + * @version: 1.5.28 * @license: MIT - * @build: Fri Sep 01 2017 23:43:13 GMT-0400 (Eastern Daylight Time) + * @build: Thu Jun 20 2019 21:18:15 GMT-0400 (Eastern Daylight Time) */ /** * Angular-Validation Directive (ghiscoding) @@ -187,7 +187,7 @@ } // invalidate field before doing any validation - if(!!value || commonObj.isFieldRequired() || _validateOnEmpty) { + if((value !== "" && value !== null && typeof value !== "undefined") || commonObj.isFieldRequired() || _validateOnEmpty) { ctrl.$setValidity('validation', false); } @@ -411,7 +411,9 @@ /** Re-evaluate the element and revalidate it, also re-attach the onBlur event on the element */ function revalidateAndAttachOnBlur() { // Revalidate the input when enabled (without displaying the error) - var value = ctrl.$modelValue || ''; + var value = ctrl.$modelValue !== null && typeof ctrl.$modelValue !== 'undefined' + ? ctrl.$modelValue + : ''; if(!Array.isArray(value)) { ctrl.$setValidity('validation', commonObj.validate(value, false)); } @@ -505,6 +507,7 @@ angular // list of available published public functions of this object validationCommon.prototype.addToValidationSummary = addToValidationSummary; // add an element to the $validationSummary validationCommon.prototype.arrayFindObject = arrayFindObject; // search an object inside an array of objects + validationCommon.prototype.arrayRemoveObject = arrayRemoveObject; // search an object inside an array of objects and remove it from array validationCommon.prototype.defineValidation = defineValidation; // define our validation object validationCommon.prototype.getFormElementByName = getFormElementByName; // get the form element custom object by it's name validationCommon.prototype.getFormElements = getFormElements; // get the array of form elements (custom objects) @@ -1210,6 +1213,25 @@ angular return null; } + /** Quick function to remove an object inside an array by it's given field name and value, return and remove the object found or null + * @param Array sourceArray + * @param string searchId: search property id + * @param string searchValue: value to search + * @return object found from source array or null + */ + function arrayRemoveObject(sourceArray, searchId, searchValue) { + if (!!sourceArray) { + for (var i = 0; i < sourceArray.length; i++) { + if (sourceArray[i][searchId] === searchValue) { + var itemToRemove = sourceArray[i]; + sourceArray.splice(i,1); + return itemToRemove; + } + } + } + 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 @@ -2860,7 +2882,7 @@ angular self.commonObj.initialize(scope, attrs.elm, attrs, attrs.ctrl); // attempt to validate & run validation callback if user requested it - var validationPromise = attemptToValidate(self, event.target.value, 0); + var validationPromise = attemptToValidate(self, (attrs.ctrl.$modelValue == undefined ? '' : attrs.ctrl.$modelValue), 0); if(!!_validationCallback) { self.commonObj.runValidationCallbackOnPromise(validationPromise, _validationCallback); } @@ -3088,9 +3110,12 @@ angular // pre-validate without any events just to pre-fill our validationSummary with all field errors // passing false as 2nd argument for not showing any errors on screen self.commonObj.validate(value, false); - + + // check field level setting for validateOnEmpty + var isFieldValidateOnEmpty = (self.commonObj.validatorAttrs && self.commonObj.validatorAttrs.validateOnEmpty); + // if field is not required and his value is empty, cancel validation and exit out - if(!self.commonObj.isFieldRequired() && !_validateOnEmpty && (value === "" || value === null || typeof value === "undefined")) { + if(!self.commonObj.isFieldRequired() && !(_validateOnEmpty || isFieldValidateOnEmpty) && (value === "" || value === null || typeof value === "undefined")) { cancelValidation(self, formElmObj); deferred.resolve({ isFieldValid: true, formElmObj: formElmObj, value: value }); return deferred.promise; @@ -3245,7 +3270,7 @@ angular var foundWatcher = self.commonObj.arrayFindObject(_watchers, 'elmName', formElmObj.fieldName); if(!!foundWatcher) { foundWatcher.watcherHandler(); // deregister the watch by calling his handler - _watchers.shift(); + self.commonObj.arrayRemoveObject(_watchers, 'elmName', formElmObj.fieldName); } // make the validation cancelled so it won't get called anymore in the blur eventHandler @@ -3328,7 +3353,7 @@ angular attrs.elm.bind('blur', _blurHandler = function(event) { if (!!formElmObj && !formElmObj.isValidationCancelled) { // attempt to validate & run validation callback if user requested it - var validationPromise = attemptToValidate(self, event.target.value, 10); + var validationPromise = attemptToValidate(self, (attrs.ctrl.$modelValue == undefined ? '' : attrs.ctrl.$modelValue), 10); if(!!_validationCallback) { self.commonObj.runValidationCallbackOnPromise(validationPromise, _validationCallback); } @@ -3350,4 +3375,4 @@ angular }); } -}]); // ValidationService \ No newline at end of file +}]); // ValidationService diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index a314179..7d230ae 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.5.24 + * @version: 1.5.28 * @license: MIT - * @build: Fri Sep 01 2017 23:43:13 GMT-0400 (Eastern Daylight Time) + * @build: Thu Jun 20 2019 21:18:15 GMT-0400 (Eastern Daylight Time) */ -angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(A){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&$.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&$.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,A=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){var e=""===a||("boolean"==typeof a?a:"undefined"!=typeof a&&n.$eval(a));e===!0?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue,n=$.getFormElementByName(l.$name);if(n&&n.hasOwnProperty("isValidationCancelled")){var t=o(i);w&&$.runValidationCallbackOnPromise(t,w)}else l.$setValidity("validation",!0)}})}}}]); -angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=E(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var l=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",s={field:n,friendlyName:l,message:t,formName:i?i.$name:null};o>=0?Q[o]=s:Q.push(s)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs&&K.controllerAs[u]?K.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;p&&(p.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation||"";if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",l=i.match(new RegExp("^/(.*?)/([gimy]*)$")),s=new RegExp(l[1],l[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:s},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function l(e){return e?A(z,"formName",e):z}function s(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=E(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=E(n,"field",e);if(i>=0&&n.splice(i,1),i=E(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var l=t&&t.translate?a.instant(e):e;l=l.trim();var s=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+s)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(l):n.after('
'+l+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,l=!0,s=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=l+(n&&n.params?String.format(a,n.params):a):p.message+=l+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,s,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=l+o:p.message+=l+o,O(i,e,p.message,s,t)})}(m,l,r)),l&&u++,i.validRequireHowMany==u&&l){s=!0;break}}return l&&(n(i,""),i.updateErrorMsg("",{isValid:l})),m&&(m.isValid=s,s&&(m.message="")),s}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),l=t&&t.friendlyName?a.instant(t.friendlyName):"",s={fieldName:i,friendlyName:l,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=E(z,"fieldName",e.attr("name"));return u>=0?z[u]=s:z.push(s),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a];if(r)return"undefined"==typeof r.$name&&(r.$name=a),r}return null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=s.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[s]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],l=n[1],s=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,l-1,s,u,p,d)}function F(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,l=e instanceof Date?e:q(e,o).getTime();if(2==t.params.length){var s=q(t.params[0],o).getTime(),u=q(t.params[1],o).getTime(),p=M(t.condition[0],l,s),d=M(t.condition[1],l,u);r=p&&d}else{var m=q(t.params[0],o).getTime();r=M(t.condition,l,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var l=!0,s="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)l=!!d;else{if("object"!=typeof d)throw u;l=!!d.isValid}if(l===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw s;O(r,n,e,!1,i)})):l===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return l}function H(e,t,r,n){var i=!0,l=t.params[0],s=r.scope.$eval(l),u=angular.element(document.querySelector('[name="'+l+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(M(t.condition,e,s)&&!!e),u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(l,function(i,o){var l=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(M(t.condition,e,s)&&!!e);if(i!==o){if(l)O(r,m,"",!0,!0);else{m.isValid=!1;var u=p.message;p.altText&&p.altText.length>0&&(u=p.altText.replace("alt=","")),a(u).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,l,!0)})}d.$setValidity("validation",l)}},!0),i}function I(e,t,a,r,n,i){var o=!0,l="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",s="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();d&&"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw s;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw s;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw l;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled,o=r.elm.prop("disabled"),l=""===o||("boolean"==typeof o?o:"undefined"!=typeof o&&r.scope.$eval(o)),s=""===i||("boolean"==typeof i?i:"undefined"!=typeof i&&r.scope.$eval(i));if(l||s)n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var u=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&u.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){F(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){F(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=l,X.prototype.getGlobalOptions=s,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); +angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(""!==i&&null!==i&&"undefined"!=typeof i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(A){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&$.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&$.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=null!==l.$modelValue&&"undefined"!=typeof l.$modelValue?l.$modelValue:"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,A=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){var e=""===a||("boolean"==typeof a?a:"undefined"!=typeof a&&n.$eval(a));e===!0?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue,n=$.getFormElementByName(l.$name);if(n&&n.hasOwnProperty("isValidationCancelled")){var t=o(i);w&&$.runValidationCallbackOnPromise(t,w)}else l.$setValidity("validation",!0)}})}}}]); +angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=x(n,e),o=V(W,"field",n);if(o>=0&&""===t)W.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var l=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",s={field:n,friendlyName:l,message:t,formName:i?i.$name:null};o>=0?W[o]=s:W.push(s)}if(e.scope.$validationSummary=W,i&&(i.$validationSummary=E(W,"formName",i.$name)),Y&&Y.controllerAs&&(Y.controllerAs.$validationSummary=W,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=Y.controllerAs&&Y.controllerAs[u]?Y.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;p&&(p.$validationSummary=E(W,"formName",i.$name))}return W}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation||"";if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",l=i.match(new RegExp("^/(.*?)/([gimy]*)$")),s=new RegExp(l[1],l[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:s},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.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 u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(K,"fieldName",e)}function l(e){return e?E(K,"formName",e):K}function s(){return Y}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=V(K,"fieldName",e);t>=0&&K.splice(t,1)}function c(e,t){var a=this,r=x(e,a),n=t||W,i=V(n,"field",e);if(i>=0&&n.splice(i,1),i=V(W,"field",e),i>=0&&W.splice(i,1),a.scope.$validationSummary=W,r&&(r.$validationSummary=E(W,"formName",r.$name)),Y&&Y.controllerAs&&(Y.controllerAs.$validationSummary=W,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;Y.controllerAs[o]&&(Y.controllerAs[o].$validationSummary=E(W,"formName",r.$name))}return W}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=T(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){Y.displayOnlyLastErrorMsg=e}function y(e){var t=this;return Y=d(Y,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var l=t&&t.translate?a.instant(e):e;l=l.trim();var s=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+s)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!Y.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(l):n.after('
'+l+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,l=!0,s=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&Y.displayOnlyLastErrorMsg?p.message=l+(n&&n.params?String.format(a,n.params):a):p.message+=l+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,s,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&Y.displayOnlyLastErrorMsg?p.message=l+o:p.message+=l+o,O(i,e,p.message,s,t)})}(m,l,r)),l&&u++,i.validRequireHowMany==u&&l){s=!0;break}}return l&&(n(i,""),i.updateErrorMsg("",{isValid:l})),m&&(m.isValid=s,s&&(m.message="")),s}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=x(i,{scope:n}),l=t&&t.friendlyName?a.instant(t.friendlyName):"",s={fieldName:i,friendlyName:l,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=V(K,"fieldName",e.attr("name"));return u>=0?K[u]=s:K.push(s),K}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(Y.preValidateValidationSummary||"undefined"==typeof Y.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||Y.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=z,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):Y&&Y.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(Y.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:Y.validRequireHowMany,X=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?q(e.validatorAttrs.validateOnEmpty):Y.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?T(t.scope,a,"."):t.scope[a];if(r)return"undefined"==typeof r.$name&&(r.$name=a),r}return null}function x(e,t){if(Y&&Y.formName){var a=document.querySelector('[name="'+Y.formName+'"]');if(a)return a.$name=Y.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=s.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[s]=u}}return null}function N(e){return!isNaN(parseFloat(e))&&isFinite(e)}function T(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=M(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=M(a,r),l=n[0],s=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=M(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=M(a,r),o=n[0],l=n[1],s=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,l-1,s,u,p,d)}function k(e){e&&(Y={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},K=[],W=[])}function M(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function C(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function L(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function U(){return this.replace(/^\s+|\s+$/g,"")}function j(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function G(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,l=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var s=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=C(t.condition[0],l,s),d=C(t.condition[1],l,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=C(t.condition,l,m)}}return r}function D(e,t){var a=!0;if(2==t.params.length){var r=C(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=C(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=C(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function H(e,a,r,n,i,o){var l=!0,s="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||X){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)l=!!d;else{if("object"!=typeof d)throw u;l=!!d.isValid}if(l===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw s;O(r,n,e,!1,i)})):l===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return l}function I(e,t,r,n){var i=!0,l=t.params[0],s=r.scope.$eval(l),u=angular.element(document.querySelector('[name="'+l+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(C(t.condition,e,s)&&!!e),u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(l,function(i,o){var l=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(C(t.condition,e,s)&&!!e);if(i!==o){if(l)O(r,m,"",!0,!0);else{m.isValid=!1;var u=p.message;p.altText&&p.altText.length>0&&(u=p.altText.replace("alt=","")),a(u).then(function(e){var t=Y.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,l,!0)})}d.$setValidity("validation",l)}},!0),i}function B(e,t,a,r,n,i){var o=!0,l="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",s="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||X){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Q.length>1)for(;Q.length>0;){var d=Q.pop();d&&"function"==typeof d.abort&&d.abort()}if(Q.push(p),!p||"function"!=typeof p.then)throw s;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Q.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw s;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw l;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function _(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled,o=r.elm.prop("disabled"),l=""===o||("boolean"==typeof o?o:"undefined"!=typeof o&&r.scope.$eval(o)),s=""===i||("boolean"==typeof i?i:"undefined"!=typeof i&&r.scope.$eval(i));if(l||s)n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var u=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&u.test(e)}return n}function J(e,t){return N(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var z=1e3,K=[],Y={resetGlobalOptionsOnRouteChange:!0},Q=[],W=[],X=!1;e.$on("$routeChangeStart",function(e,t,a){k(Y.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){k(Y.resetGlobalOptionsOnRouteChange)});var Z=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=z,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(Y=e.$validationOptions),e&&(Y.isolatedScope||Y.scope)&&(this.scope=Y.isolatedScope||Y.scope,Y=d(e.$validationOptions,Y)),"undefined"==typeof Y.resetGlobalOptionsOnRouteChange&&(Y.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return Z.prototype.addToValidationSummary=n,Z.prototype.arrayFindObject=w,Z.prototype.arrayRemoveObject=A,Z.prototype.defineValidation=i,Z.prototype.getFormElementByName=o,Z.prototype.getFormElements=l,Z.prototype.getGlobalOptions=s,Z.prototype.isFieldRequired=p,Z.prototype.initialize=u,Z.prototype.mergeObjects=d,Z.prototype.parseBool=q,Z.prototype.removeFromValidationSummary=c,Z.prototype.removeFromFormElementObjectList=m,Z.prototype.runValidationCallbackOnPromise=g,Z.prototype.setDisplayOnlyLastErrorMsg=v,Z.prototype.setGlobalOptions=y,Z.prototype.updateErrorMsg=h,Z.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=L),String.prototype.trim=U,String.prototype.format=j,String.format=P,Z}]); 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,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"EURO_SHORT",params:[n],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":d={condition:">=",dateType:"EURO_SHORT",params:[n],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":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={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=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[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":d={condition:"<=",dateType:"US_SHORT",params:[n],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":d={condition:">=",dateType:"US_SHORT",params:[n],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"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={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":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; -angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope||i.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope||i.isolatedScope,m&&(l.$validationOptions=m)}return i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);g&&n.commonObj.runValidationCallbackOnPromise(t,g)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),g=i.hasOwnProperty("validationCallback")?i.validationCallback:null,$=i.hasOwnProperty("validateOnEmpty")?n.commonObj.parseBool(i.validateOnEmpty):!!V.validateOnEmpty,O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e,o){var t=this,a="",n=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var i=0,l=e.$validationSummary.length;i0&&("function"!=typeof m.ctrl.$setTouched||o||m.ctrl.$setTouched(),t.commonObj.updateErrorMsg(e.$validationSummary[i].message,{isSubmitted:!o,isValid:m.isValid,obj:m}))}return n}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a0&&("function"!=typeof m.ctrl.$setTouched||o||m.ctrl.$setTouched(),t.commonObj.updateErrorMsg(e.$validationSummary[i].message,{isSubmitted:!o,isValid:m.isValid,obj:m}))}return n}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a