diff --git a/bower.json b/bower.json index 3fb5fb1..a9b384a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.5", + "version": "1.5.6", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 950be4c..2c97c4a 100644 --- a/dist/angular-validation.min.js +++ b/dist/angular-validation.min.js @@ -2,11 +2,11 @@ * Angular-Validation Directive and Service (ghiscoding) * http://github.com/ghiscoding/angular-validation * @author: Ghislain B. - * @version: 1.5.5 + * @version: 1.5.6 * @license: MIT - * @build: Wed Aug 31 2016 12:59:09 GMT-0400 (Eastern Daylight Time) + * @build: Sat Sep 24 2016 00:49:05 GMT-0400 (Eastern Daylight Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(w){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i,0);A&&$.runValidationCallbackOnPromise(n,A)}}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);A&&$.runValidationCallbackOnPromise(i,A)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,A=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,w=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){a?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue;if(t.isValidationCancelled)l.$setValidity("validation",!0);else{var n=o(i);A&&$.runValidationCallbackOnPromise(n,A)}}})}}}]); angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function i(e,t,r){if("undefined"!=typeof e&&null!=e){var i=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),n=E(i,e),o=w(z,"field",i);if(o>=0&&""===t)z.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var s=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",l={field:i,friendlyName:s,message:t,formName:n?n.$name:null};o>=0?z[o]=l:z.push(l)}if(e.scope.$validationSummary=z,n&&(n.$validationSummary=V(z,"formName",n.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,n&&n.$name)){var d=n.$name.indexOf(".")>=0?n.$name.split(".")[1]:n.$name,u=_.controllerAs[d]?_.controllerAs[d]:e.elm.controller()[d];u&&(u.$validationSummary=V(z,"formName",n.$name))}return z}}function n(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var i=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!i||i.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var n=i[1],o=i[2]?i[2].replace(/\|(.*)/,""):"",s=n.match(new RegExp("^/(.*?)/([gimy]*)$")),l=new RegExp(s[1],s[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:l},a=a.replace("pattern="+n,"pattern")}else if(a.indexOf("regex:")>=0){var i=a.match("regex:(.*?):regex");if(i.length<2)throw'Regex validator within the validation needs to be define with an opening "regex:" and a closing ":regex", please review your validator.';var d=i[1].split(":=");t={message:d[0],pattern:d[1]},a=a.replace(i[0],"regex:")}var u=a.split("|");if(u){e.bFieldRequired=a.indexOf("required")>=0;for(var p=0,m=u.length;p=0,g=[];f?(g=u[p].substring(0,c-1).split(":"),g.push(u[p].substring(c))):g=u[p].split(":"),e.validators[p]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return A(B,"fieldName",e)}function s(e){return e?V(B,"formName",e):B}function l(){return _}function d(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function u(){var e=this;return e.bFieldRequired}function p(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=w(B,"fieldName",e);t>=0&&B.splice(t,1)}function c(e,t){var a=this,r=E(e,a),i=t||z,n=w(i,"field",e);if(n>=0&&i.splice(n,1),n=w(z,"field",e),n>=0&&z.splice(n,1),a.scope.$validationSummary=z,r&&(r.$validationSummary=V(z,"formName",r.$name)),_&&_.controllerAs&&(_.controllerAs.$validationSummary=z,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;_.controllerAs[o]&&(_.controllerAs[o].$validationSummary=V(z,"formName",r.$name))}return z}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=x(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){_.displayOnlyLastErrorMsg=e}function y(e){var t=this;return _=p(_,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var i=t&&t.elm?t.elm:r.elm,n=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof n||null===n){var o=i?i.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var s=t&&t.translate?a.instant(e):e;s=s.trim();var l=n.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),d=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var u=r.validatorAttrs.validationErrorTo.charAt(0),p="."===u||"#"===u?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;d=angular.element(document.querySelector(p))}d&&0!==d.length||(d=angular.element(document.querySelector(".validation-"+l)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!_.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?d.length>0?d.html(s):i.after('
'+s+"
"):d.html("")}function b(e,t){var r,n=this,s=!0,l=!0,d=0,u={message:""};"undefined"==typeof e&&(e="");for(var p=n.ctrl&&n.ctrl.$name?n.ctrl.$name:n.attrs&&n.attrs.name?n.attrs.name:n.elm.attr("name"),m=o(p),c=n.validatorAttrs.rules||n.validatorAttrs.validation,f=0,g=n.validators.length;f0&&(o=i.altText.replace("alt=",""));var d=a(o);e.translatePromise=d,e.validator=i,d.then(function(a){u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+(i&&i.params?String.format(a,i.params):a):u.message+=s+(i&&i.params?String.format(a,i.params):a),O(n,e,u.message,l,t)})["catch"](function(a){if(!(i.altText&&i.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);u.message.length>0&&_.displayOnlyLastErrorMsg?u.message=s+o:u.message+=s+o,O(n,e,u.message,l,t)})}(m,s,r)),s&&d++,n.validRequireHowMany==d&&s){l=!0;break}}return s&&(i(n,""),n.updateErrorMsg("",{isValid:s})),m&&(m.isValid=l,l&&(m.message="")),l}function $(e,t,r,i){var n=t.name?t.name:e.attr("name"),o=E(n,{scope:i}),s=t&&t.friendlyName?a.instant(t.friendlyName):"",l={fieldName:n,friendlyName:s,elm:e,attrs:t,ctrl:r,scope:i,isValid:!1,message:"",formName:o?o.$name:null},d=w(B,"fieldName",e.attr("name"));return d>=0?B[d]=l:B.push(l),B}function O(e,t,a,r,n){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(_.preValidateValidationSummary||"undefined"==typeof _.preValidateValidationSummary||n)&&i(t,a),(e.validatorAttrs.preValidateFormElements||_.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),n&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&i(t,"")}function S(e){return e.typingLimit=I,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):_&&_.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(_.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:_.validRequireHowMany,K=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?N(e.validatorAttrs.validateOnEmpty):_.validateOnEmpty,e}function A(e,t,a){if(e)for(var r=0;r=0?x(t.scope,o,"."):t.scope[o]))return"undefined"==typeof a.$name&&(a.$name=o),a}if(n){var o=n?n.getAttribute("name"):null;if(o){var s={$name:o,specialNote:"Created by Angular-Validation for Isolated Scope usage"};if(_&&_.controllerAs&&o.indexOf(".")>=0){var l=o.split(".");return t.scope[l[0]][l[1]]=s}return t.scope[o]=s}}return null}function R(e){return!isNaN(parseFloat(e))&&isFinite(e)}function x(e,t,a){for(var r=a?t.split(a):t,i=0,n=r.length;i8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),l=i[0],s=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),i=q(a,r),s=i[0],l=i[1],o=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),i=q(a,r),o=i[0],s=i[1],l=i[2],n=e.length>10?e.substring(11).split(":"):null}var d=n&&3===n.length?n[0]:0,u=n&&3===n.length?n[1]:0,p=n&&3===n.length?n[2]:0;return new Date(o,s-1,l,d,u,p)}function q(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function F(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function k(){return this.replace(/^\s+|\s+$/g,"")}function L(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function M(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function C(e,t,a){var r=!0,i=r=!1;if(e instanceof Date)i=!0;else{var n=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&n.test(e)}if(i){var o=t.dateType,s=e instanceof Date?e:T(e,o).getTime();if(2==t.params.length){var l=T(t.params[0],o).getTime(),d=T(t.params[1],o).getTime(),u=F(t.condition[0],s,l),p=F(t.condition[1],s,d);r=u&&p}else{var m=T(t.params[0],o).getTime();r=F(t.condition,s,m)}}return r}function U(e,t){var a=!0;if(2==t.params.length){var r=F(t.condition[0],parseFloat(e),parseFloat(t.params[0])),i=F(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&i}else a=F(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function P(e,a,r,i,n,o){var s=!0,l="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",d="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||K){var u=a.params[0],p=f(r,u);if("boolean"==typeof p)s=!!p;else{if("object"!=typeof p)throw d;s=!!p.isValid}if(s===!1?(i.isValid=!1,t(function(){var e=o.message+" ";if(p.message&&(e+=p.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw l;O(r,i,e,!1,n)})):s===!0&&(i.isValid=!0,O(r,i,"",!0,n)),"undefined"==typeof p)throw d}return s}function j(e,t,r,i){var n=!0,s=t.params[0],l=r.scope.$eval(s),d=angular.element(document.querySelector('[name="'+s+'"]')),u=t,p=r.ctrl,m=o(r.ctrl.$name);return n=F(t.condition,e,l)&&!!e,d&&d.attr("friendly-name")?t.params[1]=d.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(s,function(e,t){var n=F(u.condition,p.$viewValue,e);if(e!==t){if(n)O(r,m,"",!0,!0);else{m.isValid=!1;var o=u.message;u.altText&&u.altText.length>0&&(o=u.altText.replace("alt=","")),a(o).then(function(e){var t=_.errorMessageSeparator||" ";i.message=t+(u&&u.params?String.format(e,u.params):e),O(r,m,i.message,n,!0)})}p.$setValidity("validation",n)}},!0),n}function G(e,t,a,r,i,n){var o=!0,s="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",l="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&i||K){a.ctrl.$processing=!0;var d=t.params[0],u=f(a,d);if(J.length>1)for(;J.length>0;){var p=J.pop();"function"==typeof p.abort&&p.abort()}if(J.push(u),!u||"function"!=typeof u.then)throw l;a.ctrl.$setValidity("remote",!1),function(e){u.then(function(t){t=t.data||t,J.pop(),a.ctrl.$processing=!1;var d=n.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw l;o=!!t.isValid}if(o===!1){if(r.isValid=!1,d+=t.message||e," "===d)throw s;O(a,r,d,!1,i)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,i))})}(t.altText)}return o}function H(e,t,a,r){var i=!0,n=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled;if(r.elm.prop("disabled")||r.scope.$eval(n))i=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())i=!1;else{var o=new RegExp(t.pattern,t.patternFlag);i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&o.test(e)}return i}function D(e,t){return R(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var I=1e3,B=[],_={resetGlobalOptionsOnRouteChange:!0},J=[],z=[],K=!1;e.$on("$routeChangeStart",function(e,t,a){_.resetGlobalOptionsOnRouteChange&&(_={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},B=[],z=[])});var Y=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=I,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(_=e.$validationOptions),e&&(_.isolatedScope||_.scope)&&(this.scope=_.isolatedScope||_.scope,_=p(e.$validationOptions,_)),"undefined"==typeof _.resetGlobalOptionsOnRouteChange&&(_.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return Y.prototype.addToValidationSummary=i,Y.prototype.arrayFindObject=A,Y.prototype.defineValidation=n,Y.prototype.getFormElementByName=o,Y.prototype.getFormElements=s,Y.prototype.getGlobalOptions=l,Y.prototype.isFieldRequired=u,Y.prototype.initialize=d,Y.prototype.mergeObjects=p,Y.prototype.parseBool=N,Y.prototype.removeFromValidationSummary=c,Y.prototype.removeFromFormElementObjectList=m,Y.prototype.runValidationCallbackOnPromise=g,Y.prototype.setDisplayOnlyLastErrorMsg=v,Y.prototype.setGlobalOptions=y,Y.prototype.updateErrorMsg=h,Y.prototype.validate=b,String.prototype.trim=k,String.prototype.format=L,String.format=M,Y}]); -angular.module("ghiscoding.validation").factory("ValidationRules",[function(){function e(e){var a="undefined"!=typeof e.altText?e.altText.replace("alt=",""):null,t=e.hasOwnProperty("customRegEx")?e.customRegEx:null,s=e.hasOwnProperty("rule")?e.rule:null,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,r={};switch(s){case"accepted":r={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":r={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";r={patternLength:"^(.|[\\r\\n]){"+_[0]+","+_[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";r={pattern:"^(.|[\\r\\n]){"+_[0]+","+_[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[_[0],_[1]],type:"regex"};break;case"betweenNum":case"between_num":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";r={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"conditionalNumber"};break;case"boolean":r={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":r={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":r={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":r={message:"",params:[n],type:"javascript"};break;case"dateEuroLong":case"date_euro_long":r={pattern:/^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.](19|20)\d\d$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";r={condition:[">=","<="],dateType:"EURO_LONG",params:[_[0],_[1]],pattern:/^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.](19|20)\d\d$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":r={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.](19|20)\d\d$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":r={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.](19|20)\d\d$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":r={pattern:/^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.]\d\d$/,message:"INVALID_DATE_EURO_SHORT",type:"regex"};break;case"dateEuroShortBetween":case"date_euro_short_between":case"betweenDateEuroShort":case"between_date_euro_short":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";r={condition:[">=","<="],dateType:"EURO_SHORT",params:[_[0],_[1]],pattern:/^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.]\d\d$/,message:"INVALID_DATE_EURO_SHORT_BETWEEN",type:"conditionalDate"};break;case"dateEuroShortMax":case"date_euro_short_max":case"maxDateEuroShort":case"max_date_euro_short":r={condition:"<=",dateType:"EURO_SHORT",params:[n],pattern:/^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.]\d\d$/,message:"INVALID_DATE_EURO_SHORT_MAX",type:"conditionalDate"};break;case"dateEuroShortMin":case"date_euro_short_min":case"minDateEuroShort":case"min_date_euro_short":r={condition:">=",dateType:"EURO_SHORT",params:[n],pattern:/^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.]\d\d$/,message:"INVALID_DATE_EURO_SHORT_MIN",type:"conditionalDate"};break;case"dateIso":case"date_iso":r={pattern:/^(19|20)\d\d([-])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";r={condition:[">=","<="],dateType:"ISO",params:[_[0],_[1]],pattern:/^(19|20)\d\d([-])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":r={condition:"<=",dateType:"ISO",params:[n],pattern:/^(19|20)\d\d([-])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":r={condition:">=",dateType:"ISO",params:[n],pattern:/^(19|20)\d\d([-])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":r={pattern:/^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.](19|20)\d\d$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";r={condition:[">=","<="],dateType:"US_LONG",params:[_[0],_[1]],pattern:/^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.](19|20)\d\d$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":r={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.](19|20)\d\d$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":r={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.](19|20)\d\d$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":r={pattern:/^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.]\d\d$/,message:"INVALID_DATE_US_SHORT",type:"regex"};break;case"dateUsShortBetween":case"date_us_short_between":case"betweenDateUsShort":case"between_date_us_short":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";r={condition:[">=","<="],dateType:"US_SHORT",params:[_[0],_[1]],pattern:/^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.]\d\d$/,message:"INVALID_DATE_US_SHORT_BETWEEN",type:"conditionalDate"};break;case"dateUsShortMax":case"date_us_short_max":case"maxDateUsShort":case"max_date_us_short":r={condition:"<=",dateType:"US_SHORT",params:[n],pattern:/^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.]\d\d$/,message:"INVALID_DATE_US_SHORT_MAX",type:"conditionalDate"};break;case"dateUsShortMin":case"date_us_short_min":case"minDateUsShort":case"min_date_us_short":r={condition:">=",dateType:"US_SHORT",params:[n],pattern:/^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.]\d\d$/,message:"INVALID_DATE_US_SHORT_MIN",type:"conditionalDate"};break;case"different":case"differentInput":case"different_input":var e=n.split(",");r={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":r={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var _=n.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";r={pattern:"^\\d{"+_[0]+","+_[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[_[0],_[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":r={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":r={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":r={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":r={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":r={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var c=RegExp().escape(n).replace(/,/g,"|");r={pattern:"^("+c+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":r={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":r={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":r={pattern:/^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$/,message:"INVALID_IPV4",type:"regex"};break;case"ipv6":r={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");r={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":r={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":r={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":r={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":r={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":r={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":r={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var c=RegExp().escape(n).replace(/,/g,"|");r={pattern:"^((?!("+c+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":r={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":r={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":r={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":r={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":r={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":r={message:"",params:[n],type:"remote"};break;case"required":r={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":r={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":r={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":r={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return r.altText=a,r}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; +angular.module("ghiscoding.validation").factory("ValidationRules",[function(){function e(e){var a="undefined"!=typeof e.altText?e.altText.replace("alt=",""):null,t=e.hasOwnProperty("customRegEx")?e.customRegEx:null,s=e.hasOwnProperty("rule")?e.rule:null,n=e.hasOwnProperty("ruleParams")?e.ruleParams:null,d={};switch(s){case"accepted":d={pattern:/^(yes|on|1|true)$/i,message:"INVALID_ACCEPTED",type:"regex"};break;case"alpha":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":d={pattern:/^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"between":case"range":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between:1,5";d={patternLength:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",messageLength:"INVALID_BETWEEN_CHAR",conditionNum:[">=","<="],messageNum:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"autoDetect"};break;case"betweenLen":case"between_len":case"stringLen":case"string_len":case"stringLength":case"string_length":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";d={pattern:"^(.|[\\r\\n]){"+r[0]+","+r[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[r[0],r[1]],type:"regex"};break;case"betweenNum":case"between_num":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";d={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[r[0],r[1]],type:"conditionalNumber"};break;case"boolean":d={pattern:/^(true|false|0|1)$/i,message:"INVALID_BOOLEAN",type:"regex"};break;case"checked":d={pattern:/^true$/i,message:"INVALID_CHECKBOX_SELECTED",type:"regex"};break;case"creditCard":case"credit_card":d={pattern:/^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$/,message:"INVALID_CREDIT_CARD",type:"regex"};break;case"custom":case"javascript":d={message:"",params:[n],type:"javascript"};break;case"dateEuro":case"date_euro":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO",type:"regex"};break;case"dateEuroBetween":case"date_euro_between":case"betweenDateEuro":case"between_date_euro":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_BETWEEN",type:"conditionalDate"};break;case"dateEuroMax":case"date_euro_max":case"maxDateEuro":case"max_date_euro":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MAX",type:"conditionalDate"};break;case"dateEuroMin":case"date_euro_min":case"minDateEuro":case"min_date_euro":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_EURO_MIN",type:"conditionalDate"};break;case"dateEuroLong":case"date_euro_long":d={pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";d={condition:[">=","<="],dateType:"EURO_LONG",params:[r[0],r[1]],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":d={condition:"<=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":d={condition:">=",dateType:"EURO_LONG",params:[n],pattern:/^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":d={pattern:/^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.]\d\d$/,message:"INVALID_DATE_EURO_SHORT",type:"regex"};break;case"dateEuroShortBetween":case"date_euro_short_between":case"betweenDateEuroShort":case"between_date_euro_short":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";d={condition:[">=","<="],dateType:"EURO_SHORT",params:[r[0],r[1]],pattern:/^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.]\d\d$/,message:"INVALID_DATE_EURO_SHORT_BETWEEN",type:"conditionalDate"};break;case"dateEuroShortMax":case"date_euro_short_max":case"maxDateEuroShort":case"max_date_euro_short":d={condition:"<=",dateType:"EURO_SHORT",params:[n],pattern:/^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.]\d\d$/,message:"INVALID_DATE_EURO_SHORT_MAX",type:"conditionalDate"};break;case"dateEuroShortMin":case"date_euro_short_min":case"minDateEuroShort":case"min_date_euro_short":d={condition:">=",dateType:"EURO_SHORT",params:[n],pattern:/^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.]\d\d$/,message:"INVALID_DATE_EURO_SHORT_MIN",type:"conditionalDate"};break;case"dateIso":case"date_iso":d={pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";d={condition:[">=","<="],dateType:"ISO",params:[r[0],r[1]],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":d={condition:"<=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":d={condition:">=",dateType:"ISO",params:[n],pattern:/^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/,message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUs":case"date_us":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US",type:"regex"};break;case"dateUsBetween":case"date_us_between":case"betweenDateUs":case"between_date_us":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_BETWEEN",type:"conditionalDate"};break;case"dateUsMax":case"date_us_max":case"maxDateUs":case"max_date_us":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MAX",type:"conditionalDate"};break;case"dateUsMin":case"date_us_min":case"minDateUs":case"min_date_us":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,message:"INVALID_DATE_US_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":d={pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";d={condition:[">=","<="],dateType:"US_LONG",params:[r[0],r[1]],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":d={condition:"<=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":d={condition:">=",dateType:"US_LONG",params:[n],pattern:/^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/,message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":d={pattern:/^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.]\d\d$/,message:"INVALID_DATE_US_SHORT",type:"regex"};break;case"dateUsShortBetween":case"date_us_short_between":case"betweenDateUsShort":case"between_date_us_short":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";d={condition:[">=","<="],dateType:"US_SHORT",params:[r[0],r[1]],pattern:/^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.]\d\d$/,message:"INVALID_DATE_US_SHORT_BETWEEN",type:"conditionalDate"};break;case"dateUsShortMax":case"date_us_short_max":case"maxDateUsShort":case"max_date_us_short":d={condition:"<=",dateType:"US_SHORT",params:[n],pattern:/^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.]\d\d$/,message:"INVALID_DATE_US_SHORT_MAX",type:"conditionalDate"};break;case"dateUsShortMin":case"date_us_short_min":case"minDateUsShort":case"min_date_us_short":d={condition:">=",dateType:"US_SHORT",params:[n],pattern:/^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.]\d\d$/,message:"INVALID_DATE_US_SHORT_MIN",type:"conditionalDate"};break;case"different":case"differentInput":case"different_input":var e=n.split(",");d={condition:"!=",message:"INVALID_INPUT_DIFFERENT",params:e,type:"matching"};break;case"digits":d={pattern:"^\\d{"+n+"}$",message:"INVALID_DIGITS",params:[n],type:"regex"};break;case"digitsBetween":case"digits_between":var r=n.split(",");if(2!==r.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: digits_between:1,5";d={pattern:"^\\d{"+r[0]+","+r[1]+"}$",message:"INVALID_DIGITS_BETWEEN",params:[r[0],r[1]],type:"regex"};break;case"email":case"emailAddress":case"email_address":d={pattern:/^[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9#~!$%^&*_=+\/`\|}{\'?]+)*@([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_][-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]*(\.[-\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_]+)*([\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]+)|(\.[\wа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":d={pattern:"^(.|[\\r\\n]){"+n+"}$",message:"INVALID_EXACT_LEN",params:[n],type:"regex"};break;case"float":d={pattern:/^\d*\.{1}\d+$/,message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":d={pattern:/^[-+]?\d*\.{1}\d+$/,message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":d={pattern:/^[a-zA-Z]{2}\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$/i,message:"INVALID_IBAN",type:"regex"};break;case"enum":case"in":case"inList":case"in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^("+_+")$",patternFlag:"i",message:"INVALID_IN_LIST",params:[n],type:"regex"};break;case"int":case"integer":d={pattern:/^\d+$/,message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":d={pattern:/^[+-]?\d+$/,message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ip":case"ipv4":d={pattern:/^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$/,message:"INVALID_IPV4",type:"regex"};break;case"ipv6":d={pattern:/^(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))$/i,message:"INVALID_IPV6",type:"regex"};break;case"compare":case"match":case"matchInput":case"match_input":case"same":var e=n.split(",");d={condition:"===",message:"INVALID_INPUT_MATCH",params:e,type:"matching"};break;case"max":d={patternLength:"^(.|[\\r\\n]){0,"+n+"}$",messageLength:"INVALID_MAX_CHAR",conditionNum:"<=",messageNum:"INVALID_MAX_NUM",params:[n],type:"autoDetect"};break;case"maxLen":case"max_len":case"maxLength":case"max_length":d={pattern:"^(.|[\\r\\n]){0,"+n+"}$",message:"INVALID_MAX_CHAR",params:[n],type:"regex"};break;case"maxNum":case"max_num":d={condition:"<=",message:"INVALID_MAX_NUM",params:[n],type:"conditionalNumber"};break;case"min":d={patternLength:"^(.|[\\r\\n]){"+n+",}$",messageLength:"INVALID_MIN_CHAR",conditionNum:">=",messageNum:"INVALID_MIN_NUM",params:[n],type:"autoDetect"};break;case"minLen":case"min_len":case"minLength":case"min_length":d={pattern:"^(.|[\\r\\n]){"+n+",}$",message:"INVALID_MIN_CHAR",params:[n],type:"regex"};break;case"minNum":case"min_num":d={condition:">=",message:"INVALID_MIN_NUM",params:[n],type:"conditionalNumber"};break;case"notIn":case"not_in":case"notInList":case"not_in_list":var _=RegExp().escape(n).replace(/,/g,"|");d={pattern:"^((?!("+_+")).)+$",patternFlag:"i",message:"INVALID_NOT_IN_LIST",params:[n],type:"regex"};break;case"numeric":d={pattern:/^\d*\.?\d+$/,message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":d={pattern:/^[-+]?\d*\.?\d+$/,message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"phone":d={pattern:/^([0-9]( |[-.])?)?((\(\d{3}\) ?)|(\d{3}[-.]))?\d{3}[-.]\d{4}$/,message:"INVALID_PHONE_US",type:"regex"};break;case"phoneInternational":case"phone_international":d={pattern:/^\+(?:[0-9]\x20?){6,14}[0-9]$/,message:"INVALID_PHONE_INTERNATIONAL",type:"regex"};break;case"pattern":case"regex":d={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"remote":d={message:"",params:[n],type:"remote"};break;case"required":d={pattern:/\S+/,message:"INVALID_REQUIRED",type:"regex"};break;case"size":d={patternLength:"^(.|[\\r\\n]){"+n+"}$",messageLength:"INVALID_EXACT_LEN",conditionNum:"==",messageNum:"INVALID_EXACT_NUM",params:[n],type:"autoDetect"};break;case"url":d={pattern:/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i,message:"INVALID_URL",type:"regex"};break;case"time":d={pattern:/^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$/,message:"INVALID_TIME",type:"regex"}}return d.altText=a,d}var a={getElementValidators:e};return a}]),RegExp.prototype.escape=function(e){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")}return e.replace(arguments.callee.sRE,"\\$1")}; angular.module("ghiscoding.validation").service("ValidationService",["$interpolate","$q","$timeout","ValidationCommon",function(e,o,t,a){function n(o,t,a){var n=this,i={};if("string"==typeof o&&"string"==typeof t?(i.elmName=o,i.rules=t,i.friendlyName="string"==typeof a?a:""):i=o,"object"!=typeof i||!i.hasOwnProperty("elmName")||!i.hasOwnProperty("rules")||!i.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";var l=i.scope?i.scope:n.validationAttrs.scope;if(i.elm=angular.element(document.querySelector('[name="'+i.elmName+'"]')),"object"!=typeof i.elm||0===i.elm.length)return n;if(new RegExp("{{(.*?)}}").test(i.elmName)&&(i.elmName=e(i.elmName)(l)),i.name=i.elmName,n.validationAttrs.isolatedScope){var m=l.$validationOptions||null;l=n.validationAttrs.isolatedScope,m&&(l.$validationOptions=m)}return $=n.validationAttrs.hasOwnProperty("validationCallback")?n.validationAttrs.validationCallback:null,g=n.validationAttrs.hasOwnProperty("validateOnEmpty")?commonObj.parseBool(n.validationAttrs.validateOnEmpty):!!V.validateOnEmpty,i.elm.bind("blur",j=function(e){var o=n.commonObj.getFormElementByName(i.elmName);if(o&&!o.isValidationCancelled){n.commonObj.initialize(l,i.elm,i,i.ctrl);var t=s(n,e.target.value,0);$&&n.commonObj.runValidationCallbackOnPromise(t,$)}}),i=n.commonObj.mergeObjects(n.validationAttrs,i),O(n,l,i),i.elm.on("$destroy",function(){var e=n.commonObj.getFormElementByName(n.commonObj.ctrl.$name);e&&(u(n,e),n.commonObj.removeFromValidationSummary(i.name))}),h.push({elmName:i.elmName,watcherHandler:f(l,i,n)}),n}function i(e){var o=this,t="",a=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var n=0,i=e.$validationSummary.length;n0&&("function"==typeof l.ctrl.$setTouched&&l.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:l.isValid,obj:l}))}return a}function l(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"clearInvalidValidatorsInSummary() requires a valid Angular Form or $scope/vm object passed as argument to work properly, for example:: fn($scope) OR fn($scope.form1) OR fn(vm) OR fn(vm.form1)";for(var t=[],a=0,n=e.$validationSummary.length;a` will display :: *Field must be different from specified field "First Name"*. * `different_input:f,t` Must be different from another input field(f), same as (different:f) but also include (t) for alternate input name to be displayed in the error message (it still uses a generic error message, if you really wish to replace the full error message then you should use `match:n:alt` see [:alt](https://github.com/ghiscoding/angular-validation/wiki/Alternate-Text-on-Validators)) @@ -204,20 +214,24 @@ All validators are written as `snake_case` but it's up to the user's taste and c * `max:n` Will auto-detect value type then use proper validator. * Type Number uses `max_num`, String use `max_len`. * `max_date_iso` Alias of `date_iso_max`. +* `max_date_euro` Alias of `date_euro_max`. * `max_date_euro_long` Alias of `date_euro_long_max`. -* `max_date_euro_short` Alias of `date_euro_short_max`. +* `max_date_euro_short` *DEPRECATED* does not support leap year, preferable to use `max_date_euro` or make a PR to fix it. +* `max_date_us` Alias of `date_us_max`. * `max_date_us_long` Alias of `date_us_long_max`. -* `max_date_us_short` Alias of `date_us_short_max`. +* `max_date_us_short` *DEPRECATED* does not support leap year, preferable to use `max_date_us` or make a PR to fix it. * `max_len:n` Checks field length, no longer than specified length where (n) is length parameter. * `max_length:n` Alias of `max_len` * `max_num:n` Checks numeric value to be lower or equal than the number (n). * `min:n` Will auto-detect value type then use proper validator. * Type Number uses `min_num`, String use `min_len`. * `min_date_iso` Alias of `date_iso_min`. +* `min_date_euro` Alias of `date_euro_min`. * `min_date_euro_long` Alias of `date_euro_long_min`. -* `min_date_euro_short` Alias of `date_euro_short_min`. +* `min_date_euro_short` *DEPRECATED* does not support leap year, preferable to use `min_date_euro` or make a PR to fix it. +* `min_date_us` Alias of `date_us_min`. * `min_date_us_long` Alias of `date_us_long_min`. -* `min_date_us_short` Alias of `date_us_short_min`. +* `min_date_us_short` *DEPRECATED* does not support leap year, preferable to use `min_date-us` or make a PR to fix it. * `min_len:n` Checks field length, no shorter than specified length where (n) is length parameter. * `min_length:n` Alias of `min_len` * `min_num:n` Checks numeric value to be higher or equal than the number (n). diff --git a/src/validation-rules.js b/src/validation-rules.js index 4765b27..1f53ec9 100644 --- a/src/validation-rules.js +++ b/src/validation-rules.js @@ -166,10 +166,62 @@ angular type: "javascript" }; break; + case "dateEuro" : + case "date_euro" : + validator = { + // accept long & short year (1996 or 96) + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_EURO", + type: "regex" + }; + break; + case "dateEuroBetween" : + case "date_euro_between" : + case "betweenDateEuro" : + case "between_date_euro" : + var ranges = ruleParams.split(','); + if (ranges.length !== 2) { + throw "This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro:01-01-1990,31-12-2015"; + } + validator = { + condition: [">=","<="], + dateType: "EURO_LONG", + params: [ranges[0], ranges[1]], + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_EURO_BETWEEN", + type: "conditionalDate" + }; + break; + case "dateEuroMax" : + case "date_euro_max" : + case "maxDateEuro" : + case "max_date_euro" : + validator = { + condition: "<=", + dateType: "EURO_LONG", + params: [ruleParams], + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_EURO_MAX", + type: "conditionalDate" + }; + break; + case "dateEuroMin" : + case "date_euro_min" : + case "minDateEuro" : + case "min_date_euro" : + validator = { + condition: ">=", + dateType: "EURO_LONG", + params: [ruleParams], + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_EURO_MIN", + type: "conditionalDate" + }; + break; case "dateEuroLong" : case "date_euro_long" : validator = { - pattern: /^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_EURO_LONG", type: "regex" }; @@ -186,7 +238,7 @@ angular condition: [">=","<="], dateType: "EURO_LONG", params: [ranges[0], ranges[1]], - pattern: /^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_EURO_LONG_BETWEEN", type: "conditionalDate" }; @@ -199,7 +251,7 @@ angular condition: "<=", dateType: "EURO_LONG", params: [ruleParams], - pattern: /^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_EURO_LONG_MAX", type: "conditionalDate" }; @@ -212,7 +264,7 @@ angular condition: ">=", dateType: "EURO_LONG", params: [ruleParams], - pattern: /^(0[1-9]|[12][0-9]|3[01])[-\/\.](0[1-9]|1[012])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:31(\/|-|\.)(?:0[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)02\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_EURO_LONG_MIN", type: "conditionalDate" }; @@ -271,7 +323,7 @@ angular case "dateIso" : case "date_iso" : validator = { - pattern: /^(19|20)\d\d([-])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/, + pattern: /^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/, message: "INVALID_DATE_ISO", type: "regex" }; @@ -288,7 +340,7 @@ angular condition: [">=","<="], dateType: "ISO", params: [ranges[0], ranges[1]], - pattern: /^(19|20)\d\d([-])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/, + pattern: /^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/, message: "INVALID_DATE_ISO_BETWEEN", type: "conditionalDate" }; @@ -301,7 +353,7 @@ angular condition: "<=", dateType: "ISO", params: [ruleParams], - pattern: /^(19|20)\d\d([-])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/, + pattern: /^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/, message: "INVALID_DATE_ISO_MAX", type: "conditionalDate" }; @@ -314,15 +366,66 @@ angular condition: ">=", dateType: "ISO", params: [ruleParams], - pattern: /^(19|20)\d\d([-])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/, + pattern: /^(?=\d)(?:(?!(?:1582(?:\-)10(?:\-)(?:0?[5-9]|1[0-4]))|(?:1752(?:\-)0?9(?:\-)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\-)(?:29|30))))(\d{4})(\-)(0{1}\d|1[012])\2((?!00)[012]{1}\d|3[01])(?:$|(?=\d)))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2})|(?:[01]\d|2[0-3])(?::[0-5]\d){2})?$/, message: "INVALID_DATE_ISO_MIN", type: "conditionalDate" }; break; + case "dateUs" : + case "date_us" : + validator = { + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_US", + type: "regex" + }; + break; + case "dateUsBetween" : + case "date_us_between" : + case "betweenDateUs" : + case "between_date_us" : + var ranges = ruleParams.split(','); + if (ranges.length !== 2) { + throw "This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us:01/01/1990,12/31/2015"; + } + validator = { + condition: [">=","<="], + dateType: "US_LONG", + params: [ranges[0], ranges[1]], + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_US_BETWEEN", + type: "conditionalDate" + }; + break; + case "dateUsMax" : + case "date_us_max" : + case "maxDateUs" : + case "max_date_us" : + validator = { + condition: "<=", + dateType: "US_LONG", + params: [ruleParams], + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_US_MAX", + type: "conditionalDate" + }; + break; + case "dateUsMin" : + case "date_us_min" : + case "minDateUs" : + case "min_date_us" : + validator = { + condition: ">=", + dateType: "US_LONG", + params: [ruleParams], + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])?00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, + message: "INVALID_DATE_US_MIN", + type: "conditionalDate" + }; + break; case "dateUsLong" : case "date_us_long" : validator = { - pattern: /^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_US_LONG", type: "regex" }; @@ -339,7 +442,7 @@ angular condition: [">=","<="], dateType: "US_LONG", params: [ranges[0], ranges[1]], - pattern: /^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_US_LONG_BETWEEN", type: "conditionalDate" }; @@ -352,7 +455,7 @@ angular condition: "<=", dateType: "US_LONG", params: [ruleParams], - pattern: /^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_US_LONG_MAX", type: "conditionalDate" }; @@ -365,7 +468,7 @@ angular condition: ">=", dateType: "US_LONG", params: [ruleParams], - pattern: /^(0[1-9]|1[012])[-\/\.](0[1-9]|[12][0-9]|3[01])[-\/\.](19|20)\d\d$/, + pattern: /^(?:(?:(?:0[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:02(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1[0-2]))(\/|-|\.)(?:0[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/, message: "INVALID_DATE_US_LONG_MIN", type: "conditionalDate" };