From 012585ad9ff5e32945188bfddf0a0a0c8e05df66 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Wed, 7 Jun 2017 22:02:38 -0400 Subject: [PATCH] Merged #157 to add Simplified Chinese locale Thanks to @wbiz for providing Simplified Chinese locale --- bower.json | 2 +- changelog.txt | 1 + dist/angular-validation.js | 4 ++-- dist/angular-validation.min.js | 4 ++-- package.json | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index c18636e..b46da93 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.21", + "version": "1.5.22", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index 0a4aea3..91ea023 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ Angular-Validation change logs +1.5.22 (2017-06-07) Merged #157 to add Simplified Chinese locale. 1.5.21 (2017-05-14) Fix #151 validation rule "different" disables rule "required". 1.5.20 (2017-04-20) Add an unminified version and Fix #153 bug in validation service. 1.5.19 (2017-04-17) Fix #150 angularValidation.revalidate problems diff --git a/dist/angular-validation.js b/dist/angular-validation.js index 124ef27..b4c22f8 100644 --- a/dist/angular-validation.js +++ b/dist/angular-validation.js @@ -2,9 +2,9 @@ * Angular-Validation Directive and Service (ghiscoding) * http://github.com/ghiscoding/angular-validation * @author: Ghislain B. - * @version: 1.5.21 + * @version: 1.5.22 * @license: MIT - * @build: Sun May 14 2017 23:35:23 GMT-0400 (Eastern Daylight Time) + * @build: Wed Jun 07 2017 22:01:12 GMT-0400 (Eastern Daylight Time) */ /** * Angular-Validation Directive (ghiscoding) diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 45b6cd1..4310a1f 100644 --- a/dist/angular-validation.min.js +++ b/dist/angular-validation.min.js @@ -2,9 +2,9 @@ * Angular-Validation Directive and Service (ghiscoding) * http://github.com/ghiscoding/angular-validation * @author: Ghislain B. - * @version: 1.5.21 + * @version: 1.5.22 * @license: MIT - * @build: Sun May 14 2017 23:35:23 GMT-0400 (Eastern Daylight Time) + * @build: Wed Jun 07 2017 22:01:12 GMT-0400 (Eastern Daylight Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$q","$timeout","ValidationCommon",function(a,e,i){return{restrict:"A",require:"ngModel",link:function(n,t,r,l){function o(i,r){var o=a.defer(),d=!1,m="undefined"!=typeof r?r:$.typingLimit,s=$.getFormElementByName(l.$name);if(Array.isArray(i)){if(O=[],h="",m=0,i.length>0)return"function"==typeof s.ctrl.$setTouched&&s.ctrl.$setTouched(),u(i,typeof i);m=0}return i&&i.badInput?c():($.validate(i,!1),$.isFieldRequired()||F||""!==i&&null!==i&&"undefined"!=typeof i?(s&&(s.isValidationCancelled=!1),(i||$.isFieldRequired()||F)&&l.$setValidity("validation",!1),"SELECT"===t.prop("tagName").toUpperCase()?(d=$.validate(i,!0),l.$setValidity("validation",d),o.resolve({isFieldValid:d,formElmObj:s,value:i}),o.promise):("undefined"!=typeof i&&(0===r?(d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i}),e.cancel(b)):($.updateErrorMsg(""),e.cancel(b),b=e(function(){d=$.validate(i,!0),n.$evalAsync(l.$setValidity("validation",d)),o.resolve({isFieldValid:d,formElmObj:s,value:i})},m))),o.promise)):(f(),o.resolve({isFieldValid:!0,formElmObj:s,value:i}),o.promise))}function d(a,e,i){var n=o(a,0);n&&"function"==typeof n.then&&(O.push(n),parseInt(e)===i-1&&O.forEach(function(a){a.then(function(a){switch(A){case"all":a.isFieldValid===!1&&a.formElmObj.translatePromise.then(function(e){h.length>0&&g.displayOnlyLastErrorMsg?h="["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e):h+=" ["+a.value+"] :: "+(a.formElmObj.validator&&a.formElmObj.validator.params?String.format(e,a.formElmObj.validator.params):e),$.updateErrorMsg(h,{isValid:!1}),$.addToValidationSummary(a.formElmObj,h)});break;case"one":default:a.isFieldValid===!0&&(l.$setValidity("validation",!0),f())}})}))}function m(a){var e=$.getFormElementByName(l.$name),i="undefined"!=typeof l.$modelValue?l.$modelValue:a.target.value;if(e&&e.hasOwnProperty("isValidationCancelled")){var n=o(i,0);w&&$.runValidationCallbackOnPromise(n,w)}else l.$setValidity("validation",!0)}function u(a,e){var i=a.length;if("string"===e)for(var n in a)d(a[n],n,i);else if("object"===e)for(var n in a)if(a.hasOwnProperty(n)){var t=a[n];for(var r in t)if(t.hasOwnProperty(r)){if(C&&r!==C)continue;d(t[r],n,i)}}}function s(){f(),$.removeFromValidationSummary(j);var a=$.arrayFindObject(E,"elmName",l.$name);if(a&&"function"==typeof a.watcherHandler){a.watcherHandler();E.shift()}}function f(){var a=$.getFormElementByName(l.$name);a&&(a.isValidationCancelled=!0),e.cancel(b),$.updateErrorMsg(""),l.$setValidity("validation",!0),V()}function v(){return n.$watch(function(){var a=l.$modelValue;if(y())return{badInput:!0};if(C&&Array.isArray(a)&&0===a.length&&Object.keys(a).length>0){var e=[],i={};return i[C]=a[C],e.push(i),e}return a},function(a,e){if(a&&a.badInput)return V(),c();var i=o(a);w&&$.runValidationCallbackOnPromise(i,w)},!0)}function c(){e.cancel(b);var a=$.getFormElementByName(l.$name);$.updateErrorMsg("INVALID_KEY_CHAR",{isValid:!1,translate:!0}),$.addToValidationSummary(a,"INVALID_KEY_CHAR",!0)}function y(){return!!t.prop("validity")&&t.prop("validity").badInput===!0}function p(){var a=l.$modelValue||"";Array.isArray(a)||l.$setValidity("validation",$.validate(a,!1));var e=$.getFormElementByName(l.$name);e&&(e.isValidationCancelled=!1),V(),t.bind("blur",m)}function V(){"function"==typeof m&&t.unbind("blur",m)}var b,$=new i(n,t,r,l),h="",O=[],E=[],g=$.getGlobalOptions(),j=r.name,w=r.hasOwnProperty("validationCallback")?r.validationCallback:null,F=r.hasOwnProperty("validateOnEmpty")?$.parseBool(r.validateOnEmpty):!!g.validateOnEmpty,A=r.hasOwnProperty("validArrayRequireHowMany")?r.validArrayRequireHowMany:"one",C=r.hasOwnProperty("validationArrayObjprop")?r.validationArrayObjprop:null;E.push({elmName:j,watcherHandler:v()}),r.$observe("disabled",function(a){var e=""===a||("boolean"==typeof a?a:"undefined"!=typeof a&&n.$eval(a));e===!0?(f(),$.removeFromValidationSummary(j)):p()}),t.on("$destroy",function(){s()}),n.$watch(function(){return t.attr("validation")},function(a){if("undefined"==typeof a||""===a)s();else{$.defineValidation(),p();var e=$.arrayFindObject(E,"elmName",l.$name);e||E.push({elmName:j,watcherHandler:v()})}}),t.bind("blur",m),n.$on("angularValidation.revalidate",function(a,e){if(e==l.$name){l.revalidateCalled=!0;var i=l.$modelValue,n=$.getFormElementByName(l.$name);if(n&&n.hasOwnProperty("isValidationCancelled")){var t=o(i);w&&$.runValidationCallbackOnPromise(t,w)}else l.$setValidity("validation",!0)}})}}}]); angular.module("ghiscoding.validation").factory("ValidationCommon",["$rootScope","$timeout","$translate","ValidationRules",function(e,t,a,r){function n(e,t,r){if("undefined"!=typeof e&&null!=e){var n=e.ctrl&&e.ctrl.$name?e.ctrl.$name:e.attrs&&e.attrs.name?e.attrs.name:e.elm.attr("name"),i=R(n,e),o=E(Q,"field",n);if(o>=0&&""===t)Q.splice(o,1);else if(""!==t){r&&(t=a.instant(t));var l=e.attrs&&e.friendlyName?a.instant(e.friendlyName):"",s={field:n,friendlyName:l,message:t,formName:i?i.$name:null};o>=0?Q[o]=s:Q.push(s)}if(e.scope.$validationSummary=Q,i&&(i.$validationSummary=A(Q,"formName",i.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,i&&i.$name)){var u=i.$name.indexOf(".")>=0?i.$name.split(".")[1]:i.$name,p=K.controllerAs&&K.controllerAs[u]?K.controllerAs[u]:"undefined"!=typeof e.elm.controller()?e.elm.controller()[u]:null;p&&(p.$validationSummary=A(Q,"formName",i.$name))}return Q}}function i(){var e=this,t={};e.validators=[],e=S(e);var a=e.validatorAttrs.rules||e.validatorAttrs.validation;if(a.indexOf("pattern=/")>=0){var n=a.match(/pattern=(\/(?:(?!:alt).)*\/[igm]*)(:alt=(.*))?/);if(!n||n.length<3)throw'Regex validator within the validation needs to be define with an opening "/" and a closing "/", please review your validator.';var i=n[1],o=n[2]?n[2].replace(/\|(.*)/,""):"",l=i.match(new RegExp("^/(.*?)/([gimy]*)$")),s=new RegExp(l[1],l[2]);t={altMsg:o,message:o.replace(/:alt=/,""),pattern:s},a=a.replace("pattern="+i,"pattern")}else if(a.indexOf("regex:")>=0){var n=a.match("regex:(.*?):regex");if(n.length<2)throw'Regex validator within the validation needs to be define with an opening "regex:" and a closing ":regex", please review your validator.';var u=n[1].split(":=");t={message:u[0],pattern:u[1]},a=a.replace(n[0],"regex:")}var p=a.split("|");if(p){e.bFieldRequired=a.indexOf("required")>=0;for(var d=0,m=p.length;d=0,g=[];f?(g=p[d].substring(0,c-1).split(":"),g.push(p[d].substring(c))):g=p[d].split(":"),e.validators[d]=r.getElementValidators({altText:f===!0?2===g.length?g[1]:g[2]:"",customRegEx:t,rule:g[0],ruleParams:f&&2===g.length?null:g[1]})}}return e}function o(e){return w(z,"fieldName",e)}function l(e){return e?A(z,"formName",e):z}function s(){return K}function u(e,t,a,r){this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,$(t,a,r,e),this.defineValidation()}function p(){var e=this;return e.bFieldRequired}function d(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a}function m(e){var t=E(z,"fieldName",e);t>=0&&z.splice(t,1)}function c(e,t){var a=this,r=R(e,a),n=t||Q,i=E(n,"field",e);if(i>=0&&n.splice(i,1),i=E(Q,"field",e),i>=0&&Q.splice(i,1),a.scope.$validationSummary=Q,r&&(r.$validationSummary=A(Q,"formName",r.$name)),K&&K.controllerAs&&(K.controllerAs.$validationSummary=Q,r)){var o=r.$name.indexOf(".")>=0?r.$name.split(".")[1]:r.$name;K.controllerAs[o]&&(K.controllerAs[o].$validationSummary=A(Q,"formName",r.$name))}return Q}function f(e,t){var a;if(/\({1}.*\){1}/gi.test(t))a=e.scope.$eval(t);else{var r=N(e.scope,t,".");"function"==typeof r&&(a=r())}return a}function g(e,t){var a=this;"function"==typeof e.then&&e.then(function(){f(a,t)})}function v(e){K.displayOnlyLastErrorMsg=e}function y(e){var t=this;return K=d(K,e),t}function h(e,t){var r=this;t&&t.obj&&(r=t.obj,r.validatorAttrs=t.obj.attrs);var n=t&&t.elm?t.elm:r.elm,i=n&&n.attr("name")?n.attr("name"):null;if("undefined"==typeof i||null===i){var o=n?n.attr("ng-model"):"unknown";throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+o+'"'}var l=t&&t.translate?a.instant(e):e;l=l.trim();var s=i.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,"").replace(/\./g,"-"),u=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var p=r.validatorAttrs.validationErrorTo.charAt(0),d="."===p||"#"===p?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;u=angular.element(document.querySelector(d))}u&&0!==u.length||(u=angular.element(document.querySelector(".validation-"+s)));var m=!(!t||!t.isSubmitted)&&t.isSubmitted;!K.hideErrorUnderInputs&&t&&!t.isValid&&(m||r.ctrl.$dirty||r.ctrl.$touched||r.ctrl.revalidateCalled)?(u.length>0?u.html(l):n.after('
'+l+"
"),r.ctrl.isErrorMessageVisible=!0):(u.html(""),r.ctrl.isErrorMessageVisible=void 0)}function b(e,t){var r,i=this,l=!0,s=!0,u=0,p={message:""};"undefined"==typeof e&&(e="");for(var d=i.ctrl&&i.ctrl.$name?i.ctrl.$name:i.attrs&&i.attrs.name?i.attrs.name:i.elm.attr("name"),m=o(d),c=i.validatorAttrs.rules||i.validatorAttrs.validation,f=0,g=i.validators.length;f0&&(o=n.altText.replace("alt=",""));var u=a(o);e.translatePromise=u,e.validator=n,u.then(function(a){p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=l+(n&&n.params?String.format(a,n.params):a):p.message+=l+(n&&n.params?String.format(a,n.params):a),O(i,e,p.message,s,t)})["catch"](function(a){if(!(n.altText&&n.altText.length>0))throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.",a);p.message.length>0&&K.displayOnlyLastErrorMsg?p.message=l+o:p.message+=l+o,O(i,e,p.message,s,t)})}(m,l,r)),l&&u++,i.validRequireHowMany==u&&l){s=!0;break}}return l&&(n(i,""),i.updateErrorMsg("",{isValid:l})),m&&(m.isValid=s,s&&(m.message="")),s}function $(e,t,r,n){var i=t.name?t.name:e.attr("name"),o=R(i,{scope:n}),l=t&&t.friendlyName?a.instant(t.friendlyName):"",s={fieldName:i,friendlyName:l,elm:e,attrs:t,ctrl:r,scope:n,isValid:!1,message:"",formName:o?o.$name:null},u=E(z,"fieldName",e.attr("name"));return u>=0?z[u]=s:z.push(s),z}function O(e,t,a,r,i){a=a.trim(),t&&t.isValidationCancelled===!0&&(a=""),(K.preValidateValidationSummary||"undefined"==typeof K.preValidateValidationSummary||i)&&n(t,a),(e.validatorAttrs.preValidateFormElements||K.preValidateFormElements)&&(t&&"function"==typeof e.ctrl.$setTouched&&t.ctrl.$setTouched(),e.ctrl.$dirty===!1&&h(a,{isSubmitted:!0,isValid:r,obj:t})),i&&t&&!t.isValid?e.updateErrorMsg(a,{isValid:r,obj:t}):t&&t.isValid&&n(t,"")}function S(e){return e.typingLimit=J,e.validatorAttrs.hasOwnProperty("debounce")?e.typingLimit=parseInt(e.validatorAttrs.debounce,10):e.validatorAttrs.hasOwnProperty("typingLimit")?e.typingLimit=parseInt(e.validatorAttrs.typingLimit,10):K&&K.hasOwnProperty("debounce")&&(e.typingLimit=parseInt(K.debounce,10)),e.validRequireHowMany=e.validatorAttrs.hasOwnProperty("validRequireHowMany")?e.validatorAttrs.validRequireHowMany:K.validRequireHowMany,W=e.validatorAttrs.hasOwnProperty("validateOnEmpty")?T(e.validatorAttrs.validateOnEmpty):K.validateOnEmpty,e}function w(e,t,a){if(e)for(var r=0;r=0?N(t.scope,a,"."):t.scope[a],parentForm)?("undefined"==typeof parentForm.$name&&(parentForm.$name=a),parentForm):null}function R(e,t){if(K&&K.formName){var a=document.querySelector('[name="'+K.formName+'"]');if(a)return a.$name=K.formName,a}for(var r=document.getElementsByName(e),a=null,n=0;n=0){var p=s.split(".");return t.scope[p[0]][p[1]]=u}return t.scope[s]=u}}return null}function x(e){return!isNaN(parseFloat(e))&&isFinite(e)}function N(e,t,a){for(var r=a?t.split(a):t,n=0,i=r.length;n8?e.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),s=n[0],l=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=e.substring(0,10),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=e.substring(0,8),r=e.substring(2,3),n=k(a,r),l=n[0],s=n[1],o=parseInt(n[2])<50?"20"+n[2]:"19"+n[2],i=e.length>8?e.substring(9).split(":"):null;break;case"ISO":default:a=e.substring(0,10),r=e.substring(4,5),n=k(a,r),o=n[0],l=n[1],s=n[2],i=e.length>10?e.substring(11).split(":"):null}var u=i&&3===i.length?i[0]:0,p=i&&3===i.length?i[1]:0,d=i&&3===i.length?i[2]:0;return new Date(o,l-1,s,u,p,d)}function q(e){e&&(K={displayOnlyLastErrorMsg:!1,errorMessageSeparator:" ",hideErrorUnderInputs:!1,preValidateFormElements:!1,preValidateValidationSummary:!0,isolatedScope:null,scope:null,validateOnEmpty:!1,validRequireHowMany:"all",resetGlobalOptionsOnRouteChange:!0},z=[],Q=[])}function k(e,t){var a=[];switch(t){case"/":a=e.split("/");break;case".":a=e.split(".");break;case"-":default:a=e.split("-")}return a}function M(e,t,a){var r=!1;switch(e){case"<":r=t":r=t>a;break;case">=":r=t>=a;break;case"!=":case"<>":r=t!=a;break;case"!==":r=t!==a;break;case"=":case"==":r=t==a;break;case"===":r=t===a;break;default:r=!1}return r}function C(){Element.prototype.closest=function(e){var t,a=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do for(t=a.length;--t>=0&&a.item(t)!==r;);while(t<0&&(r=r.parentElement));return r}}function L(){return this.replace(/^\s+|\s+$/g,"")}function U(){var e=Array.isArray(arguments[0])?arguments[0]:arguments;return this.replace(/{(\d+)}/g,function(t,a){return"undefined"!=typeof e[a]?e[a]:t})}function P(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,a){return"undefined"!=typeof t[a]?t[a]:e})}function j(e,t,a){var r=!0,n=r=!1;if(e instanceof Date)n=!0;else{var i=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&i.test(e)}if(n){var o=t.dateType,l=e instanceof Date?e:F(e,o).getTime();if(2==t.params.length){var s=F(t.params[0],o).getTime(),u=F(t.params[1],o).getTime(),p=M(t.condition[0],l,s),d=M(t.condition[1],l,u);r=p&&d}else{var m=F(t.params[0],o).getTime();r=M(t.condition,l,m)}}return r}function G(e,t){var a=!0;if(2==t.params.length){var r=M(t.condition[0],parseFloat(e),parseFloat(t.params[0])),n=M(t.condition[1],parseFloat(e),parseFloat(t.params[1]));a=r&&n}else a=M(t.condition,parseFloat(e),parseFloat(t.params[0]));return a}function D(e,a,r,n,i,o){var l=!0,s="Custom Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom javascript function as { isValid: bool, message: 'your error' }",u="Custom Javascript Validation requires a declared function (in your Controller), please review your code.";if(e||W){var p=a.params[0],d=f(r,p);if("boolean"==typeof d)l=!!d;else{if("object"!=typeof d)throw u;l=!!d.isValid}if(l===!1?(n.isValid=!1,t(function(){var e=o.message+" ";if(d.message&&(e+=d.message||a.altText)," "===e&&a.altText&&(e+=a.altText)," "===e)throw s;O(r,n,e,!1,i)})):l===!0&&(n.isValid=!0,O(r,n,"",!0,i)),"undefined"==typeof d)throw u}return l}function H(e,t,r,n){var i=!0,l=t.params[0],s=r.scope.$eval(l),u=angular.element(document.querySelector('[name="'+l+'"]')),p=t,d=r.ctrl,m=o(r.ctrl.$name);return i=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(M(t.condition,e,s)&&!!e),u&&u.attr("friendly-name")?t.params[1]=u.attr("friendly-name"):t.params.length>1&&(t.params[1]=t.params[1]),r.scope.$watch(l,function(i,o){var l=!((!t.pattern||"/\\S+/"===t.pattern.toString()||rules&&"required"===t.pattern)&&null===e)&&(M(t.condition,e,s)&&!!e);if(i!==o){if(l)O(r,m,"",!0,!0);else{m.isValid=!1;var u=p.message;p.altText&&p.altText.length>0&&(u=p.altText.replace("alt=","")),a(u).then(function(e){var t=K.errorMessageSeparator||" ";n.message=t+(p&&p.params?String.format(e,p.params):e),O(r,m,n.message,l,!0)})}d.$setValidity("validation",l)}},!0),i}function I(e,t,a,r,n,i){var o=!0,l="Remote Javascript Validation requires an error message defined as 'alt=' in your validator or defined in your custom remote function as { isValid: bool, message: 'your error' }",s="Remote Validation requires a declared function (in your Controller) which also needs to return a Promise, please review your code.";if(e&&n||W){a.ctrl.$processing=!0;var u=t.params[0],p=f(a,u);if(Y.length>1)for(;Y.length>0;){var d=Y.pop();d&&"function"==typeof d.abort&&d.abort()}if(Y.push(p),!p||"function"!=typeof p.then)throw s;a.ctrl.$setValidity("remote",!1),function(e){p.then(function(t){t=t.data||t,Y.pop(),a.ctrl.$processing=!1;var u=i.message+" ";if("boolean"==typeof t)o=!!t;else{if("object"!=typeof t)throw s;o=!!t.isValid}if(o===!1){if(r.isValid=!1,u+=t.message||e," "===u)throw l;O(a,r,u,!1,n)}else o===!0&&(r.isValid=!0,a.ctrl.$setValidity("remote",!0),O(a,r,"",!0,n))})}(t.altText)}return o}function B(e,t,a,r){var n=!0,i=r.attrs?r.attrs.ngDisabled:r.validatorAttrs.ngDisabled,o=r.elm.prop("disabled"),l=""===o||("boolean"==typeof o?o:"undefined"!=typeof o&&r.scope.$eval(o)),s=""===i||("boolean"==typeof i?i:"undefined"!=typeof i&&r.scope.$eval(i));if(l||s)n=!0;else if("string"==typeof e&&""===e&&r.elm.prop("type")&&"NUMBER"===r.elm.prop("type").toUpperCase())n=!1;else{var u=new RegExp(t.pattern,t.patternFlag);n=!((!t.pattern||"/\\S+/"===t.pattern.toString()||a&&"required"===t.pattern)&&null===e)&&u.test(e)}return n}function _(e,t){return x(t)?{condition:e.conditionNum,message:e.messageNum,params:e.params,type:"conditionalNumber"}:{pattern:e.patternLength,message:e.messageLength,params:e.params,type:"regex"}}var J=1e3,z=[],K={resetGlobalOptionsOnRouteChange:!0},Y=[],Q=[],W=!1;e.$on("$routeChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)}),e.$on("$stateChangeStart",function(e,t,a){q(K.resetGlobalOptionsOnRouteChange)});var X=function(e,t,a,r){this.bFieldRequired=!1,this.validators=[],this.typingLimit=J,this.scope=e,this.elm=t,this.ctrl=r,this.validatorAttrs=a,this.validateOnEmpty=!1,this.validRequireHowMany="all",e&&e.$validationOptions&&(K=e.$validationOptions),e&&(K.isolatedScope||K.scope)&&(this.scope=K.isolatedScope||K.scope,K=d(e.$validationOptions,K)),"undefined"==typeof K.resetGlobalOptionsOnRouteChange&&(K.resetGlobalOptionsOnRouteChange=!0),this.elm&&this.validatorAttrs&&this.ctrl&&this.scope&&($(this.elm,this.validatorAttrs,this.ctrl,this.scope),this.defineValidation())};return X.prototype.addToValidationSummary=n,X.prototype.arrayFindObject=w,X.prototype.defineValidation=i,X.prototype.getFormElementByName=o,X.prototype.getFormElements=l,X.prototype.getGlobalOptions=s,X.prototype.isFieldRequired=p,X.prototype.initialize=u,X.prototype.mergeObjects=d,X.prototype.parseBool=T,X.prototype.removeFromValidationSummary=c,X.prototype.removeFromFormElementObjectList=m,X.prototype.runValidationCallbackOnPromise=g,X.prototype.setDisplayOnlyLastErrorMsg=v,X.prototype.setGlobalOptions=y,X.prototype.updateErrorMsg=h,X.prototype.validate=b,window.Element&&!Element.prototype.closest&&(Element.prototype.closest=C),String.prototype.trim=L,String.prototype.format=U,String.format=P,X}]); diff --git a/package.json b/package.json index 08ede07..895d399 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.5.21", + "version": "1.5.22", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": "dist/angular-validation.min",