From 3219b4d7429e8ccc7f0d3dc8258613af96e03d11 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Tue, 23 Feb 2016 21:09:40 -0500 Subject: [PATCH] Breaking Change rename ValidationService issue #107 - new 1.5.x branch has a breaking change, which is the fix of the uppercase on ValidationService object (instead of validationService which was wrong has mentioned in issue #107). - added angular-validation-ghiscoding to NPM and fixed the .npmignore --- .gitignore | 5 ++++ .npmignore | 13 ++++++---- app.js | 20 +++++++------- bower.json | 2 +- dist/angular-validation.min.js | 12 ++++----- full-tests/app.js | 10 +++---- more-examples/addon-3rdParty/app.js | 4 +-- more-examples/angular-ui-calendar/app.js | 8 +++--- more-examples/controllerAsWithRoute/app.js | 18 ++++++------- more-examples/customRemote/app.js | 14 +++++----- more-examples/customValidation/app.js | 14 +++++----- .../customValidationOnEmptyField/app.js | 4 +-- more-examples/dynamic-form/app.js | 4 +-- .../dynamic-modal-with-numeric-input/app.js | 4 +-- more-examples/interpolateValidation/app.js | 6 ++--- more-examples/ngIfShowHideDisabled/app.js | 6 ++--- more-examples/ui-mask/app.js | 6 ++--- more-examples/validRequireHowMany/app.js | 14 +++++----- package.json | 18 ++++++------- readme.md | 2 +- src/validation-common.js | 4 +-- src/validation-directive.js | 4 +-- src/validation-rules.js | 2 +- src/validation-service.js | 26 +++++++++---------- 24 files changed, 114 insertions(+), 106 deletions(-) diff --git a/.gitignore b/.gitignore index 770de10..088c748 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ +################# +## bower Package +################# +bower_components/ + ################# ## NPM Package ################# diff --git a/.npmignore b/.npmignore index 1e922fd..087b123 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,9 @@ -full-tests -more-examples -protractor -templates +bower_components/ +full-tests/ +more-examples/ +protractor/ +templates/ .gitignore -app.js \ No newline at end of file +app.js +gulpfile.js +index.html \ No newline at end of file diff --git a/app.js b/app.js index fd1e1ee..2eec4a0 100644 --- a/app.js +++ b/app.js @@ -38,7 +38,7 @@ myApp.controller('Ctrl', ['$location', '$route', '$scope', '$translate', functio // -- Controller to use Angular-Validation Directive // ----------------------------------------------- -myApp.controller('CtrlValidationDirective', ['$q', '$scope', 'validationService', function ($q, $scope, validationService) { +myApp.controller('CtrlValidationDirective', ['$q', '$scope', 'ValidationService', function ($q, $scope, ValidationService) { // you can change default debounce globally $scope.$validationOptions = { debounce: 1500, preValidateFormElements: false }; @@ -49,13 +49,13 @@ myApp.controller('CtrlValidationDirective', ['$q', '$scope', 'validationService' // remove a single element ($scope.form1, string) // OR you can also remove multiple elements through an array type .removeValidator($scope.form1, ['input2','input3']) $scope.removeInputValidator = function ( elmName ) { - new validationService().removeValidator($scope.form1, elmName); + new ValidationService().removeValidator($scope.form1, elmName); }; $scope.resetForm = function() { - new validationService().resetForm($scope.form1); + new ValidationService().resetForm($scope.form1); }; $scope.submitForm = function() { - if(new validationService().checkFormValidity($scope.form1)) { + if(new ValidationService().checkFormValidity($scope.form1)) { alert('All good, proceed with submit...'); } } @@ -83,11 +83,11 @@ myApp.controller('CtrlValidationDirective', ['$q', '$scope', 'validationService' // -- Controller to use Angular-Validation Directive with 2 forms // on this page we will pre-validate the form and show all errors on page load // --------------------------------------------------------------- -myApp.controller('Ctrl2forms', ['validationService', function (validationService) { +myApp.controller('Ctrl2forms', ['ValidationService', function (ValidationService) { var vm = this; // use the ControllerAs alias syntax // set the global options BEFORE any function declarations, we will prevalidate current form - var myValidationService = new validationService({ controllerAs: vm, debounce: 500, preValidateFormElements: true }); + var myValidationService = new ValidationService({ controllerAs: vm, debounce: 500, preValidateFormElements: true }); vm.submitForm = function() { if(myValidationService.checkFormValidity(vm.form01)) { @@ -106,9 +106,9 @@ myApp.controller('Ctrl2forms', ['validationService', function (validationService // ----------------------------------------------- // exact same testing form used except that all validators are programmatically added inside controller via Angular-Validation Service -myApp.controller('CtrlValidationService', ['$q', '$scope', '$translate', 'validationService', function ($q, $scope, $translate, validationService) { +myApp.controller('CtrlValidationService', ['$q', '$scope', '$translate', 'ValidationService', function ($q, $scope, $translate, ValidationService) { // start by creating the service - var myValidation = new validationService(); + var myValidation = new ValidationService(); // you can create indepent call to the validation service // also below the multiple properties available @@ -183,7 +183,7 @@ myApp.controller('CtrlValidationService', ['$q', '$scope', '$translate', 'valida // -- Controller to use Angular-Validation with Directive and ngRepeat // --------------------------------------------------------------- -myApp.controller('CtrlNgRepeat', ['$scope', 'validationService', function ($scope, validationService) { +myApp.controller('CtrlNgRepeat', ['$scope', 'ValidationService', function ($scope, ValidationService) { // Form data $scope.people = [ { name: 'John', age: 20 }, @@ -192,7 +192,7 @@ myApp.controller('CtrlNgRepeat', ['$scope', 'validationService', function ($scop ]; $scope.submitForm = function() { - if(new validationService().checkFormValidity($scope.form01)) { + if(new ValidationService().checkFormValidity($scope.form01)) { alert('All good, proceed with submit...'); } } diff --git a/bower.json b/bower.json index 0c580ea..7793835 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.4.22", + "version": "1.5.0", "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 f96d6bc..424d6c6 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.4.21 + * @version: 1.5.0 * @license: MIT - * @build: Thu Jan 21 2016 12:43:16 GMT-0500 (Eastern Standard Time) + * @build: Tue Feb 23 2016 20:30:25 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,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){if(a&&a.badInput)return V(),c();var e=o(a);F&&$.runValidationCallbackOnPromise(e,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 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(z,"field",n);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:n,friendlyName:s,message:t,formName:i?i.$name:null};o>=0?z[o]=l:z.push(l)}if(e.scope.$validationSummary=z,i&&(i.$validationSummary=w(z,"formName",i.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,i&&i.$name)){var d=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,u=_.controllerAs[d]?_.controllerAs[d]:e.elm.controller()[d];u&&(u.$validationSummary=w(z,"formName",i.$name))}return z}}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 d=n[1].split(":=");t={message:d[0],pattern:d[1]},a=a.replace(n[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].split(":"),f=u[p].indexOf("alt=")>=0;e.validators[p]=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 A(B,"fieldName",e)}function s(e){return e?w(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=V(B,"fieldName",e);t>=0&&B.splice(t,1)}function c(e,t){var a=this,r=E(e,a),n=t||z,i=V(n,"field",e);if(i>=0&&n.splice(i,1),i=V(z,"field",e),i>=0&&z.splice(i,1),a.scope.$validationSummary=z,r&&(r.$validationSummary=w(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=w(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 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,"-"),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):n.after('
'+s+"
"):d.html("")}function b(e,t){var r,i=this,s=!0,l=!0,d=0,u={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;g>f;f++){r=i.validators[f],"autoDetect"===r.type&&(r=D(r,e));var v=i.attrs?i.attrs.ngDisabled:i.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,i,m,t,u);break;case"matching":s=G(e,r,i,u);break;case"remote":s=H(e,r,i,m,t,u);break;default:s=P(e,r,c,i)}if((!i.bFieldRequired&&!e&&!K||i.elm.prop("disabled")||i.scope.$eval(v))&&(s=!0),s||(l=!1,function(e,r,n){var o=n.message,s=_.errorMessageSeparator||" ";n.altText&&n.altText.length>0&&(o=n.altText.replace("alt=",""));var d=a(o);e.translatePromise=d,e.validator=n,d.then(function(a){u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+(n&&n.params?String.format(a,n.params):a):u.message+=s+(n&&n.params?String.format(a,n.params):a),$(i,e,u.message,l,t)})["catch"](function(){n.altText&&n.altText.length>0&&(u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+o:u.message+=s+o,$(i,e,u.message,l,t))})}(m,s,r)),s&&d++,i.validRequireHowMany==d&&s){l=!0;break}}return s&&(n(i,""),i.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function O(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},d=V(B,"fieldName",e.attr("name"));return d>=0?B[d]=l:B.push(l),B}function $(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(_.preValidateValidationSummary||"undefined"==typeof _.preValidateValidationSummary||i)&&n(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})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(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(i){var o=i?i.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,n=0,i=r.length;i>n;n++)e[r[n]]&&(e=e[r[n]]);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="-",n=[],i=[],o="",s="",l="";switch(t.toUpperCase()){case"EURO_LONG":case"EURO-LONG":a=e.substring(0,10),r=e.substring(2,3),n=q(a,r),l=n[0],s=n[1],o=n[2],i=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),n=q(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=q(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=q(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=q(a,r),o=n[0],s=n[1],l=n[2],i=e.length>10?e.substring(11).split(":"):null}var d=i&&3===i.length?i[0]:0,u=i&&3===i.length?i[1]:0,p=i&&3===i.length?i[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,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?!1: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(),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])),n=F(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=F(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' }",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?(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;$(r,n,e,!1,i)})):s===!0&&(n.isValid=!0,$(r,n,"",!0,i)),"undefined"==typeof p)throw d}return s}function G(e,t,r,n){var i=!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 i=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 i=F(u.condition,p.$viewValue,e);if(e!==t){if(i)$(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||" ";n.message=t+(u&&u.params?String.format(e,u.params):e),$(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||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=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,d+=t.message||e," "===d)throw s;$(a,r,d,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),$(a,r,"",!0,n))})}(t.altText)}return o}function P(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?!1:o.test(e)}return n}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(){_.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=n,Y.prototype.arrayFindObject=A,Y.prototype.defineValidation=i,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":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":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:/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|6(?:011|5[0-9]{2})[0-9]{12}|(?:2131|1800|35\d{3})\d{11})$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"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":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"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"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":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":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"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;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",["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("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":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":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:/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|6(?:011|5[0-9]{2})[0-9]{12}|(?:2131|1800|35\d{3})\d{11})$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"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":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"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"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":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":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"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;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/full-tests/app.js b/full-tests/app.js index 0d95cf9..ffeab06 100644 --- a/full-tests/app.js +++ b/full-tests/app.js @@ -38,7 +38,7 @@ myApp.controller('Ctrl', ['$location', '$route', '$scope', '$translate', functio // -- Controller to use Angular-Validation with Directive // ------------------------------------------------------- -myApp.controller('CtrlValidationDirective', ['$scope', '$translate', 'validationService', function ($scope, $translate, validationService) { +myApp.controller('CtrlValidationDirective', ['$scope', '$translate', 'ValidationService', function ($scope, $translate, ValidationService) { $scope.$validationOptions = { debounce: 50 }; // set the debounce globally with very small time for faster Protactor sendKeys() $scope.switchLanguage = function (key) { @@ -49,7 +49,7 @@ myApp.controller('CtrlValidationDirective', ['$scope', '$translate', 'validation $scope.validations = explodeAndFlattenValidatorArray(validatorDataset); $scope.submitForm = function() { - if(new validationService().checkFormValidity($scope.form01)) { + if(new ValidationService().checkFormValidity($scope.form01)) { alert('All good, proceed with submit...'); } } @@ -60,12 +60,12 @@ myApp.controller('CtrlValidationDirective', ['$scope', '$translate', 'validation // -- Controller to use Angular-Validation with Service // ------------------------------------------------------- -myApp.controller('CtrlValidationService', ['$scope', '$translate', 'validationService', function ($scope, $translate, validationService) { +myApp.controller('CtrlValidationService', ['$scope', '$translate', 'ValidationService', function ($scope, $translate, ValidationService) { var validatorDataset = loadData(); $scope.validations = explodeAndFlattenValidatorArray(validatorDataset); // start by creating the service - var myValidation = new validationService(); + var myValidation = new ValidationService(); myValidation.setGlobalOptions({ debounce: 50, scope: $scope }) for(var i = 0, ln = $scope.validations.length; i < ln; i++) { @@ -80,7 +80,7 @@ myApp.controller('CtrlValidationService', ['$scope', '$translate', 'validationSe }; $scope.submitForm = function() { - if(new validationService().checkFormValidity($scope.form01)) { + if(new ValidationService().checkFormValidity($scope.form01)) { alert('All good, proceed with submit...'); } } diff --git a/more-examples/addon-3rdParty/app.js b/more-examples/addon-3rdParty/app.js index 78cb346..7f65947 100644 --- a/more-examples/addon-3rdParty/app.js +++ b/more-examples/addon-3rdParty/app.js @@ -15,9 +15,9 @@ myApp.config(['$compileProvider', function ($compileProvider) { $translateProvider.preferredLanguage('en').fallbackLanguage('en'); }]); -myApp.controller('Ctrl', ['validationService', function (validationService) { +myApp.controller('Ctrl', ['ValidationService', function (ValidationService) { var vm = this; - var myValidation = new validationService({ controllerAs: vm, formName: 'vm.test', preValidateFormElements: false }); + var myValidation = new ValidationService({ controllerAs: vm, formName: 'vm.test', preValidateFormElements: false }); vm.tags1 = [ { id: 1, text: 'Tag1' }, diff --git a/more-examples/angular-ui-calendar/app.js b/more-examples/angular-ui-calendar/app.js index eaaa0a3..5a63914 100644 --- a/more-examples/angular-ui-calendar/app.js +++ b/more-examples/angular-ui-calendar/app.js @@ -15,8 +15,8 @@ myApp.config(['$compileProvider', function ($compileProvider) { }]); myApp.controller('Ctrl', -['$scope', '$translate', 'validationService', '$timeout', -function ($scope, $translate, validationService, $timeout) { +['$scope', '$translate', 'ValidationService', '$timeout', +function ($scope, $translate, ValidationService, $timeout) { var vm = this; vm.model = {}; vm.validationRequired = false; @@ -37,8 +37,8 @@ function ($scope, $translate, validationService, $timeout) { vm.isChangeDatePickerOpen = true; }; - var validation = new validationService({ - controllerAs: vm, + var validation = new ValidationService({ + controllerAs: vm, preValidateFormElements: false }); diff --git a/more-examples/controllerAsWithRoute/app.js b/more-examples/controllerAsWithRoute/app.js index 2f09f60..284d316 100644 --- a/more-examples/controllerAsWithRoute/app.js +++ b/more-examples/controllerAsWithRoute/app.js @@ -45,27 +45,27 @@ myApp.config(['$compileProvider', function ($compileProvider) { }]); myApp.controller('Ctrl', [ - 'validationService', - function (validationService) { + 'ValidationService', + function (ValidationService) { var vm = this; vm.model = {}; - var v1 = new validationService({ controllerAs: vm, resetGlobalOptionsOnRouteChange: false }); + var v1 = new ValidationService({ controllerAs: vm, resetGlobalOptionsOnRouteChange: false }); }]); myApp.controller('FirstCtrl', [ - 'validationService', - function (validationService) { + 'ValidationService', + function (ValidationService) { var vm = this; vm.model = {}; - var v2 = new validationService({ controllerAs: vm }); + var v2 = new ValidationService({ controllerAs: vm }); } ]); myApp.controller('SecondCtrl', [ - 'validationService', - function (validationService) { + 'ValidationService', + function (ValidationService) { var vm = this; vm.model = {}; - var v3 = new validationService({ controllerAs: vm }); + var v3 = new ValidationService({ controllerAs: vm }); } ]); \ No newline at end of file diff --git a/more-examples/customRemote/app.js b/more-examples/customRemote/app.js index 9f720ee..8efdcc3 100644 --- a/more-examples/customRemote/app.js +++ b/more-examples/customRemote/app.js @@ -18,12 +18,12 @@ myApp.config(['$compileProvider', function ($compileProvider) { // -- // Directive -myApp.controller('CtrlDirective', ['$q', 'validationService', function ($q, validationService) { +myApp.controller('CtrlDirective', ['$q', 'ValidationService', function ($q, ValidationService) { var vmd = this; vmd.model = {}; - // use the validationService only to declare the controllerAs syntax - var vs = new validationService({ controllerAs: vmd, debounce: 500 }); + // use the ValidationService only to declare the controllerAs syntax + var vs = new ValidationService({ controllerAs: vmd, debounce: 500 }); vmd.myRemoteValidation1 = function() { var deferred = $q.defer(); @@ -54,12 +54,12 @@ myApp.controller('CtrlDirective', ['$q', 'validationService', function ($q, vali // -- // Service -myApp.controller('CtrlService', ['$scope', '$q', 'validationService', function ($scope, $q, validationService) { +myApp.controller('CtrlService', ['$scope', '$q', 'ValidationService', function ($scope, $q, ValidationService) { var vms = this; vms.model = {}; - // use the validationService only to declare the controllerAs syntax - var vs = new validationService({ controllerAs: vms, debounce: 500 }); + // use the ValidationService only to declare the controllerAs syntax + var vs = new ValidationService({ controllerAs: vms, debounce: 500 }); vs.setGlobalOptions({ scope: $scope }) .addValidator('input3', 'alpha|min_len:2|remote:vms.myRemoteValidation3():alt=Alternate error message.|required') @@ -86,7 +86,7 @@ myApp.controller('CtrlService', ['$scope', '$q', 'validationService', function ( } vms.submitForm = function() { - if(new validationService().checkFormValidity(vms.form2)) { + if(new ValidationService().checkFormValidity(vms.form2)) { alert('All good, proceed with submit...'); } } diff --git a/more-examples/customValidation/app.js b/more-examples/customValidation/app.js index d6e1ed1..27a0755 100644 --- a/more-examples/customValidation/app.js +++ b/more-examples/customValidation/app.js @@ -18,12 +18,12 @@ myApp.config(['$compileProvider', function ($compileProvider) { // -- // Directive -myApp.controller('CtrlDirective', ['validationService', function (validationService) { +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 }); + // use the ValidationService only to declare the controllerAs syntax + var vs = new ValidationService({ controllerAs: vmd }); vmd.myCustomValidation1 = function() { // you can return a boolean for isValid or an objec (see the next function) @@ -50,12 +50,12 @@ myApp.controller('CtrlDirective', ['validationService', function (validationServ // -- // Service -myApp.controller('CtrlService', ['$scope', 'validationService', function ($scope, validationService) { +myApp.controller('CtrlService', ['$scope', 'ValidationService', function ($scope, ValidationService) { var vms = this; vms.model = {}; - // use the validationService only to declare the controllerAs syntax - var vs = new validationService({ controllerAs: vms }); + // use the ValidationService only to declare the controllerAs syntax + var vs = new ValidationService({ controllerAs: vms }); vs.setGlobalOptions({ scope: $scope }) .addValidator('input3', 'alpha|min_len:2|custom:vms.myCustomValidation3:alt=Alternate error message.|required') @@ -80,7 +80,7 @@ myApp.controller('CtrlService', ['$scope', 'validationService', function ($scope } vms.submitForm = function() { - if(new validationService().checkFormValidity(vms.form2)) { + if(new ValidationService().checkFormValidity(vms.form2)) { alert('All good, proceed with submit...'); } } diff --git a/more-examples/customValidationOnEmptyField/app.js b/more-examples/customValidationOnEmptyField/app.js index 554b30c..f5b5bf0 100644 --- a/more-examples/customValidationOnEmptyField/app.js +++ b/more-examples/customValidationOnEmptyField/app.js @@ -23,7 +23,7 @@ myApp.run(function ($rootScope) { }); angular.module('emptyCustomValidation.controllers', []). -controller('myController', function($scope, validationService) { +controller('myController', function($scope, ValidationService) { $scope.existingEmployees = [ { firstName: 'John', @@ -44,7 +44,7 @@ controller('myController', function($scope, validationService) { ]; $scope.submit = function() { - if (!new validationService().checkFormValidity($scope.inputForm)) { + if (!new ValidationService().checkFormValidity($scope.inputForm)) { var msg = ''; $scope.inputForm.$validationSummary.forEach(function (validationItem) { msg += validationItem.message + '\n'; diff --git a/more-examples/dynamic-form/app.js b/more-examples/dynamic-form/app.js index 3ff06e8..857bc63 100644 --- a/more-examples/dynamic-form/app.js +++ b/more-examples/dynamic-form/app.js @@ -22,7 +22,7 @@ app.directive('formField',function() { } }); -app.controller('MainCtrl', function($scope,validationService) { +app.controller('MainCtrl', function($scope,ValidationService) { $scope.name = 'World'; $scope.items={}; $scope.items.item1 = { @@ -65,7 +65,7 @@ app.controller('MainCtrl', function($scope,validationService) { for(var key in $scope.items) { var formName=$scope.items[key].formName; - if(new validationService().checkFormValidity($scope[formName])) { + if(new ValidationService().checkFormValidity($scope[formName])) { $scope[formName].isValid = true; } else { diff --git a/more-examples/dynamic-modal-with-numeric-input/app.js b/more-examples/dynamic-modal-with-numeric-input/app.js index f1644f8..d772772 100644 --- a/more-examples/dynamic-modal-with-numeric-input/app.js +++ b/more-examples/dynamic-modal-with-numeric-input/app.js @@ -34,10 +34,10 @@ app.controller('ListController',['$scope', function($scope) { $scope.items = [{"id": 1},{"id": 2}]; }]); -app.controller('ModalController', ['$scope', '$modal', 'validationService', function ($scope, $modal, validationService) { +app.controller('ModalController', ['$scope', '$modal', 'ValidationService', function ($scope, $modal, ValidationService) { "use strict"; - var myValidation = new validationService({ formName: 'itemsEdit' }); + var myValidation = new ValidationService({ formName: 'itemsEdit' }); $scope.animationsEnabled = true; diff --git a/more-examples/interpolateValidation/app.js b/more-examples/interpolateValidation/app.js index 61295b9..fbdf20d 100644 --- a/more-examples/interpolateValidation/app.js +++ b/more-examples/interpolateValidation/app.js @@ -15,12 +15,12 @@ myApp.config(['$compileProvider', function ($compileProvider) { }]); myApp.controller('Ctrl', -['$scope', '$translate', 'validationService', -function ($scope, $translate, validationService) { +['$scope', '$translate', 'ValidationService', +function ($scope, $translate, ValidationService) { var vm = this; vm.model = {}; vm.validationRequired = true; - var validation = new validationService({ controllerAs: vm, preValidateFormElements: true }); + var validation = new ValidationService({ controllerAs: vm, preValidateFormElements: true }); vm.f1Validation = function () { return vm.validationRequired ? 'required' : ''; diff --git a/more-examples/ngIfShowHideDisabled/app.js b/more-examples/ngIfShowHideDisabled/app.js index 299fca3..c18ee59 100644 --- a/more-examples/ngIfShowHideDisabled/app.js +++ b/more-examples/ngIfShowHideDisabled/app.js @@ -13,10 +13,10 @@ myApp.config(['$translateProvider', function ($translateProvider) { $translateProvider.preferredLanguage('en').fallbackLanguage('en'); }]); -myApp.controller('Ctrl', ['$scope', 'validationService', - function($scope, validationService) { +myApp.controller('Ctrl', ['$scope', 'ValidationService', + function($scope, ValidationService) { - var validate = new validationService({ debounce: 100, isolatedScope: $scope}); + var validate = new ValidationService({ debounce: 100, isolatedScope: $scope}); $scope.ModelData = {}; $scope.ModelData.IsShowNote = false; diff --git a/more-examples/ui-mask/app.js b/more-examples/ui-mask/app.js index 84783e0..31721fc 100644 --- a/more-examples/ui-mask/app.js +++ b/more-examples/ui-mask/app.js @@ -15,13 +15,13 @@ myApp.config(['$compileProvider', function ($compileProvider) { }]); myApp.controller('Ctrl', -['$scope', '$translate', 'validationService', '$timeout', -function ($scope, $translate, validationService, $timeout) { +['$scope', '$translate', 'ValidationService', '$timeout', +function ($scope, $translate, ValidationService, $timeout) { var vm = this; vm.model = {}; function next(form) { - var vs = new validationService(); + var vs = new ValidationService(); if (vs.checkFormValidity(form)) { // proceed to another view }; diff --git a/more-examples/validRequireHowMany/app.js b/more-examples/validRequireHowMany/app.js index 7c1450a..3fdf537 100644 --- a/more-examples/validRequireHowMany/app.js +++ b/more-examples/validRequireHowMany/app.js @@ -18,12 +18,12 @@ myApp.config(['$compileProvider', function ($compileProvider) { // -- // Directive -myApp.controller('CtrlDirective', ['validationService', function (validationService) { +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 }); + // use the ValidationService only to declare the controllerAs syntax + var vs = new ValidationService({ controllerAs: vmd }); vmd.submitForm = function() { if(vs.checkFormValidity(vmd.form1)) { @@ -34,12 +34,12 @@ myApp.controller('CtrlDirective', ['validationService', function (validationServ // -- // Service -myApp.controller('CtrlService', ['$scope', 'validationService', function ($scope, validationService) { +myApp.controller('CtrlService', ['$scope', 'ValidationService', function ($scope, ValidationService) { var vms = this; vms.model = {}; - // use the validationService only to declare the controllerAs syntax - var vs = new validationService({ controllerAs: vms }); + // use the ValidationService only to declare the controllerAs syntax + var vs = new ValidationService({ controllerAs: vms }); vs.addValidator({ elmName: 'input2', @@ -49,7 +49,7 @@ myApp.controller('CtrlService', ['$scope', 'validationService', function ($scope }); vms.submitForm = function() { - if(new validationService().checkFormValidity(vms.form2)) { + if(new ValidationService().checkFormValidity(vms.form2)) { alert('All good, proceed with submit...'); } } diff --git a/package.json b/package.json index f7ce750..297cd6b 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,23 @@ { "name": "angular-validation-ghiscoding", - "version": "1.4.22", + "version": "1.5.0", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": "app.js", "dependencies": {}, "devDependencies": { - "del": "^1.1.1", + "del": "^1.2.1", "gulp": "^3.9.0", - "gulp-bump": "^0.3.0", - "gulp-concat": "^2.5.2", + "gulp-bump": "^0.3.1", + "gulp-concat": "^2.6.0", + "gulp-header": "^1.7.1", "gulp-if": "^1.2.5", "gulp-order": "^1.1.1", - "gulp-header": "^1.2.2", "gulp-replace-task": "^0.1.0", - "gulp-strip-debug": "^1.0.2", - "gulp-uglify": "^1.1.0", - "semver": "^4.3.3", - "yargs": "^3.8.0" + "gulp-strip-debug": "^1.1.0", + "gulp-uglify": "^1.5.3", + "semver": "^4.3.6", + "yargs": "^3.32.0" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/readme.md b/readme.md index 0f54e0d..3a08908 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ #Angular Validation (Directive / Service) -`Version: 1.4.22` +`Version: 1.5.0` ### Form validation after user stop typing (default 1sec). Forms Validation with Angular made easy! Angular-Validation is an angular directive/service with locales (languages) with a very simple approach of defining your `validation=""` directly within your element to validate (input, textarea, etc) and...that's it!!! The directive/service will take care of the rest! diff --git a/src/validation-common.js b/src/validation-common.js index 5126ddd..6ab6276 100644 --- a/src/validation-common.js +++ b/src/validation-common.js @@ -8,7 +8,7 @@ */ angular .module('ghiscoding.validation') - .factory('validationCommon', ['$rootScope', '$timeout', '$translate', 'validationRules', function ($rootScope, $timeout, $translate, validationRules) { + .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 @@ -241,7 +241,7 @@ angular // check if user provided an alternate text to his validator (validator:alt=Alternate Text) var hasAltText = validations[i].indexOf("alt=") >= 0; - self.validators[i] = validationRules.getElementValidators({ + self.validators[i] = ValidationRules.getElementValidators({ altText: hasAltText === true ? (params.length === 2 ? params[1] : params[2]) : '', customRegEx: customUserRegEx, rule: params[0], diff --git a/src/validation-directive.js b/src/validation-directive.js index 8396969..b8b879c 100644 --- a/src/validation-directive.js +++ b/src/validation-directive.js @@ -12,13 +12,13 @@ */ angular .module('ghiscoding.validation', ['pascalprecht.translate']) - .directive('validation', ['$q', '$timeout', 'validationCommon', function($q, $timeout, validationCommon) { + .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 commonObj = new ValidationCommon(scope, elm, attrs, ctrl); var _arrayErrorMessage = ''; var _promises = []; var _timer; diff --git a/src/validation-rules.js b/src/validation-rules.js index b559747..a59eed0 100644 --- a/src/validation-rules.js +++ b/src/validation-rules.js @@ -12,7 +12,7 @@ */ angular .module('ghiscoding.validation') - .factory('validationRules', [function () { + .factory('ValidationRules', [function () { // return the service object var service = { getElementValidators: getElementValidators diff --git a/src/validation-service.js b/src/validation-service.js index 22e5ba6..5d3204b 100644 --- a/src/validation-service.js +++ b/src/validation-service.js @@ -9,7 +9,7 @@ */ angular .module('ghiscoding.validation') - .service('validationService', ['$interpolate', '$q', '$timeout', 'validationCommon', function ($interpolate, $q, $timeout, validationCommon) { + .service('ValidationService', ['$interpolate', '$q', '$timeout', 'ValidationCommon', function ($interpolate, $q, $timeout, ValidationCommon) { // global variables of our object (start with _var) var _blurHandler; var _watchers = []; @@ -18,11 +18,11 @@ angular var _globalOptions; // service constructor - var validationService = function (globalOptions) { + 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 + this.commonObj = new ValidationCommon(); // Object of validationCommon service // if global options were passed to the constructor if (!!globalOptions) { @@ -33,15 +33,15 @@ angular } // 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 + 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; + return ValidationService; //---- // Public Functions declaration @@ -143,7 +143,7 @@ angular return self; } // addValidator() - /** Check the form validity (can be called by an empty validationService and used by both Directive/Service) + /** 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 * @return bool isFormValid @@ -590,4 +590,4 @@ angular }); } -}]); // validationService \ No newline at end of file +}]); // ValidationService \ No newline at end of file