diff --git a/app.js b/app.js index 58920d6..7c3de0a 100644 --- a/app.js +++ b/app.js @@ -82,8 +82,10 @@ myApp.controller('CtrlValidationService', ['$scope', '$translate', 'validationSe var myValidation = new validationService(); // you can create indepent call to the validation service + // also below the multiple properties available myValidation.addValidator({ elmName: 'input2', + // friendlyName: $translate.instant('FIRST_NAME'), debounce: 3000, scope: $scope, rules: 'numeric_signed|required' @@ -91,17 +93,19 @@ myApp.controller('CtrlValidationService', ['$scope', '$translate', 'validationSe // you can also chain validation service and add multiple validators at once // we optionally start by defining some global options. Note: each validator can overwrite individually these properties (ex.: validatorX can have a `debounce` different than the global set) - // there is 2 ways to write a call... #1 with elementName & rules defined as 2 strings arguments ... #2 with 1 object as argument (with defined property names) - // #1 .addValidtor('myElementName', 'myRules') ... #2 .addValidator({ elmName: 'inputX', rules: 'myRules'}) + // there is 2 ways to write a call... #1-2 with elementName & rules defined as 2 or 3 strings arguments ... #3 with 1 object as argument (with defined property names) + // #1 .addValidtor('myElementName', 'myRules') + // #2 .addValidtor('myElementName', 'myRules', 'myFriendlyName') + // #3 .addValidator({ elmName: 'inputX', rules: 'myRules'}) // the available object properties are the exact same set as the directive except that they are camelCase myValidation .setGlobalOptions({ debounce: 1500, scope: $scope }) .addValidator('input3', 'float_signed|between_num:-0.6,99.5|required') .addValidator('input4', 'exact_len:4|regex:YYWW:=^(0[9]|1[0-9]|2[0-9]|3[0-9])(5[0-2]|[0-4][0-9])$:regex|required|integer') - .addValidator('input5', 'email|required|min_len:6') + .addValidator('input5', 'email|required|min_len:6', $translate.instant('INPUT5')) // 3rd argument being the Friendly name .addValidator('input6', 'url|required') .addValidator('input7', 'ipv4|required') - .addValidator('input8', 'credit_card|required') + .addValidator('input8', 'credit_card|required', $translate.instant('INPUT8')) // 3rd argument being the Friendly name .addValidator('input9', 'between_len:2,6|required') .addValidator('input10', 'date_iso|required') .addValidator('input11', 'date_us_long|required') diff --git a/bower.json b/bower.json index eaaf9c3..79e858c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.3.21", + "version": "1.3.22", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": [ diff --git a/changelog.txt b/changelog.txt index ee3dcd0..992ccd2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -22,4 +22,5 @@ Angular-Validation change logs 1.3.18 (2015-04-19) Fixed issue #20 - Error messages shown on submit are non-understandable, this was fixed using $translate promises instead of $translate.instant(). Fixed a few error display on the validationSummary() and checkFormValidity(). Also merged #27 to add Russian 1.3.19 (2015-04-20) Fixed issue #28 - unbind all 'blur' in cancelValidation() might affect other modules 1.3.20 (2015-04-21) Fixed issue #26 - validation of forms inside ng-repeat (added sample `dynamicFormView` in `more-examples` folder). And again issue #28 - unbind all 'blur' in cancelValidation() might affect other modules. -1.3.21 (2015-04-29) Moved the Alternate Text inside the $translate promise as well which removes possible delay of non-translated text appearing as alternate text (this will not affect regular text, or already translated text). Also cleanup code and made my Gulp task even more automated. \ No newline at end of file +1.3.21 (2015-04-29) Moved the Alternate Text inside the $translate promise as well which removes possible delay of non-translated text appearing as alternate text (this will not affect regular text, or already translated text). Also cleanup code and made my Gulp task even more automated. +1.3.22 (2015-05-03) Added new element attribute of `friendly-name` which is used ONLY in the ValidationSummary, this friendly name is to give a better element name display, which also support translation, inside the ValidationSummary instead of just "input1" (see ValidationSummary for more details). \ No newline at end of file diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 1443d05..fb78f32 100644 --- a/dist/angular-validation.min.js +++ b/dist/angular-validation.min.js @@ -2,11 +2,11 @@ * Angular-Validation Directive and Service (ghiscoding) * http://github.com/ghiscoding/angular-validation * @author: Ghislain B. - * @version: 1.3.21 + * @version: 1.3.22 * @license: MIT - * @build: Wed Apr 29 2015 23:22:07 GMT-0400 (Eastern Daylight Time) + * @build: Sun May 03 2015 21:56:31 GMT-0400 (Eastern Daylight Time) */ angular.module("ghiscoding.validation",["pascalprecht.translate"]).directive("validation",["$timeout","validationCommon","validationRules",function(i,t){return{restrict:"A",require:"ngModel",link:function(a,e,n,d){function l(){v=!0,i.cancel(r),s.updateErrorMsg(""),d.$setValidity("validation",!0),"undefined"!=typeof u&&e.unbind("blur",u)}function o(t){return s.validate(t,!1),s.isFieldRequired()||""!==t&&null!==t&&"undefined"!=typeof t?(v=!1,(t||s.isFieldRequired())&&d.$setValidity("validation",!1),e.bind("blur",u=function(){v||a.$evalAsync(d.$setValidity("validation",s.validate(t,!0)))}),""!==t&&"undefined"!=typeof t||"NUMBER"!==e.prop("type").toUpperCase()?"SELECT"===e.prop("tagName").toUpperCase()?(d.$setValidity("validation",s.validate(t,!0)),t):("undefined"!=typeof t&&(s.updateErrorMsg(""),i.cancel(r),r=i(function(){a.$evalAsync(d.$setValidity("validation",s.validate(t,!0)))},s.typingLimit)),t):(i.cancel(r),d.$setValidity("validation",s.validate(t,!0)),t)):(l(),t)}var r,u,s=new t(a,e,n,d),v=!1;d.$formatters.unshift(o),d.$parsers.unshift(o),n.$observe("disabled",function(i){i?d.$setValidity("validation",!0):d.$setValidity("validation",s.validate(d.$viewValue,!0))})}}}]); -angular.module("ghiscoding.validation").factory("validationCommon",["$timeout","$translate","validationRules",function(t,e,a){function r(){var t=this,e={};t.validators=[],t.typingLimit=x,t.validatorAttrs.hasOwnProperty("debounce")?t.typingLimit=parseInt(t.validatorAttrs.debounce,10):t.validatorAttrs.hasOwnProperty("typingLimit")?t.typingLimit=parseInt(t.validatorAttrs.typingLimit,10):t.scope.$validationOptions&&t.scope.$validationOptions.hasOwnProperty("debounce")&&(t.typingLimit=parseInt(t.scope.$validationOptions.debounce,10));var r=t.validatorAttrs.hasOwnProperty("rules")?t.validatorAttrs.rules:t.validatorAttrs.validation;if(r.indexOf("regex:")>=0){var i=r.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 n=i[1].split(":=");e={message:n[0],pattern:n[1]},r=r.replace(i[0],"regex:")}var s=r.split("|");if(s){t.bFieldRequired=r.indexOf("required")>=0?!0:!1;for(var l=0,o=s.length;o>l;l++){var d=s[l].split(":"),u=s[l].indexOf("alt=")>=0?!0:!1;t.validators[l]=a.getElementValidators({altText:u===!0?2===d.length?d[1]:d[2]:"",customRegEx:e,rule:d[0],ruleParams:u&&2===d.length?null:d[1]})}}return t}function i(t){return g(R,"fieldName",t)}function n(){return R}function s(t,e,a,r){this.scope=t,this.elm=e,this.ctrl=r,this.validatorAttrs=a,m(e,a,r,t),this.defineValidation()}function l(){var t=this;return t.bFieldRequired}function o(t){var e=h(R,"fieldName",t);e>=0&&R.splice(e,1)}function d(t,e){var a=h(t,"field",e);a>=0&&t.splice(a,1),a=h(S,"field",e),a>=0&&S.splice(a,1)}function u(t,a){var r=this;a&&a.obj&&(r=a.obj,r.validatorAttrs=a.obj.attrs);var i=a&&a.elm?a.elm:r.elm,n=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof n||null===n)throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+i.attr("ng-model")+'"';var s=a&&a.translate?e.instant(t):t,l=n.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,""),o=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var d=r.validatorAttrs.validationErrorTo.charAt(0),u="."===d||"#"===d?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;o=angular.element(document.querySelector(u))}o&&0!==o.length||(o=angular.element(document.querySelector(".validation-"+l)));var p=a&&a.isSubmitted?a.isSubmitted:!1;a&&!a.isValid&&(p||r.ctrl.$dirty||r.ctrl.$touched)?o.length>0?o.text(s):i.after(''+s+""):o.text("")}function p(t,a){for(var r,n,s=this,l=!0,o=!0,d="",u=s.validatorAttrs&&s.validatorAttrs.name?s.validatorAttrs.name:s.attrs&&s.attrs.name?s.attrs.name:s.elm.attr("name"),p=i(u),m=s.validatorAttrs.hasOwnProperty("rules")?s.validatorAttrs.rules:s.validatorAttrs.validation,g=0,f=s.validators.length;f>g;g++){if(n=s.validators[g],"conditionalDate"===n.type){if(r=new RegExp(n.pattern,"i"),l="\\S+"!==n.pattern||"undefined"!=typeof t&&null!==t?r.test(t):!1){var h=n.dateType,b=y(t,h).getTime();if(2==n.params.length){var A=y(n.params[0],h).getTime(),x=y(n.params[1],h).getTime(),R=E(n.condition[0],b,A),S=E(n.condition[1],b,x);l=R&&S?!0:!1}else{var T=y(n.params[0],h).getTime();l=E(n.condition,b,T)}}}else if("conditionalNumber"===n.type)if(2==n.params.length){var R=E(n.condition[0],parseFloat(t),parseFloat(n.params[0])),S=E(n.condition[1],parseFloat(t),parseFloat(n.params[1]));l=R&&S?!0:!1}else l=E(n.condition,parseFloat(t),parseFloat(n.params[0]));else if("match"===n.type){var w=n.params[0],F=s.scope.$eval(w);l=F===t}else s.elm.prop("disabled")||1==parseInt(s.elm.attr("ng-disabled"))||"true"===s.elm.attr("ng-disabled")?l=!0:"string"==typeof t&&""===t&&"NUMBER"===s.elm.prop("type").toUpperCase()?(l=!1,d=e.instant("INVALID_KEY_CHAR")):(r=new RegExp(n.pattern,"i"),l=!("\\S+"===n.pattern||m&&m.indexOf("required")>=0)||"undefined"!=typeof t&&null!==t?r.test(t):!1);(!s.bFieldRequired&&!t||s.elm.prop("disabled")||1==parseInt(s.elm.attr("ng-disabled"))||"true"===s.elm.attr("ng-disabled"))&&(l=!0),l||(o=!1,function(t,r,i){var n=i.message;i.altText&&i.altText.length>0&&(n=i.altText.replace("alt=","")),e(n).then(function(e){d+=" "+O(i,e),c(s,t,d,o,a)})["catch"](function(){i.altText&&i.altText.length>0&&(d+=" "+n,c(s,t,d,o,a))})}(p,l,n))}return l&&(v(s,""),s.updateErrorMsg("",{isValid:l})),p&&(p.isValid=o,o&&(p.message="")),o}function m(t,e,a,r){var i=e.name?e.name:t.attr("name"),n={fieldName:i,elm:t,attrs:e,ctrl:a,scope:r,isValid:!1,message:""},s=h(R,"fieldName",t.attr("name"));return s>=0?R[s]=n:R.push(n),R}function c(t,e,a,r,i){a=a.trim(),v(e,a),e&&(e.message=a),i&&!e.isValid?t.updateErrorMsg(a,{isValid:r}):e&&e.isValid&&v(e,"")}function v(t,e){var a=t.validatorAttrs&&t.validatorAttrs.name?t.validatorAttrs.name:t.attrs&&t.attrs.name?t.attrs.name:t.elm.attr("name"),r=b(a,t),i=h(S,"field",a);if(i>=0&&""===e)S.splice(i,1);else if(""!==e){var n={field:a,message:e,formName:r?r.$name:null};i>=0?S[i]=n:S.push(n)}return t.scope.$validationSummary=S,r&&(r.$validationSummary=f(S,"formName",r.$name)),S}function g(t,e,a){for(var r=0;r8?t.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=t.substring(0,8),r=t.substring(2,3),i=A(a,r),o=i[0],l=i[1],s=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=t.length>8?t.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=t.substring(0,10),r=t.substring(2,3),i=A(a,r),l=i[0],o=i[1],s=i[2],n=t.length>8?t.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=t.substring(0,8),r=t.substring(2,3),i=A(a,r),l=i[0],o=i[1],s=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=t.length>8?t.substring(9).split(":"):null;break;case"ISO":default:a=t.substring(0,10),r=t.substring(4,5),i=A(a,r),s=i[0],l=i[1],o=i[2],n=t.length>10?t.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(s,l-1,o,d,u,p)}function O(t,e){if(t&&t.params)for(var a=0,r=t.params.length;r>a;a++)"match"===t.type&&r>1&&0===a||(e=e.replace(":param",t.params[a]));return e}function A(t,e){var a=[];switch(e){case"/":a=t.split("/");break;case".":a=t.split(".");break;case"-":default:a=t.split("-")}return a}function E(t,e,a){var r=!1;switch(t){case"<":r=a>e?!0:!1;break;case"<=":r=a>=e?!0:!1;break;case">":r=e>a?!0:!1;break;case">=":r=e>=a?!0:!1;break;case"!=":case"<>":r=e!=a?!0:!1;break;case"=":case"==":r=e==a?!0:!1;break;default:r=!1}return r}var x=1e3,R=[],S=[],T=function(t,e,a,r){this.timer=null,this.bFieldRequired=!1,this.validators=[],this.typingLimit=x,this.scope=t,this.elm=e,this.ctrl=r,this.validatorAttrs=a,t&&e&&a&&r&&(m(e,a,r,t),this.defineValidation())};return T.prototype.defineValidation=r,T.prototype.getFormElementByName=i,T.prototype.getFormElements=n,T.prototype.isFieldRequired=l,T.prototype.initialize=s,T.prototype.updateErrorMsg=u,T.prototype.validate=p,T.prototype.removeFromValidationSummary=d,T.prototype.removeFromFormElementObjectList=o,T}]); +angular.module("ghiscoding.validation").factory("validationCommon",["$timeout","$translate","validationRules",function(t,e,a){function r(){var t=this,e={};t.validators=[],t.typingLimit=x,t.validatorAttrs.hasOwnProperty("debounce")?t.typingLimit=parseInt(t.validatorAttrs.debounce,10):t.validatorAttrs.hasOwnProperty("typingLimit")?t.typingLimit=parseInt(t.validatorAttrs.typingLimit,10):t.scope.$validationOptions&&t.scope.$validationOptions.hasOwnProperty("debounce")&&(t.typingLimit=parseInt(t.scope.$validationOptions.debounce,10));var r=t.validatorAttrs.hasOwnProperty("rules")?t.validatorAttrs.rules:t.validatorAttrs.validation;if(r.indexOf("regex:")>=0){var i=r.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 n=i[1].split(":=");e={message:n[0],pattern:n[1]},r=r.replace(i[0],"regex:")}var s=r.split("|");if(s){t.bFieldRequired=r.indexOf("required")>=0?!0:!1;for(var l=0,o=s.length;o>l;l++){var d=s[l].split(":"),u=s[l].indexOf("alt=")>=0?!0:!1;t.validators[l]=a.getElementValidators({altText:u===!0?2===d.length?d[1]:d[2]:"",customRegEx:e,rule:d[0],ruleParams:u&&2===d.length?null:d[1]})}}return t}function i(t){return g(R,"fieldName",t)}function n(){return R}function s(t,e,a,r){this.scope=t,this.elm=e,this.ctrl=r,this.validatorAttrs=a,m(e,a,r,t),this.defineValidation()}function l(){var t=this;return t.bFieldRequired}function o(t){var e=h(R,"fieldName",t);e>=0&&R.splice(e,1)}function d(t,e){var a=h(t,"field",e);a>=0&&t.splice(a,1),a=h(N,"field",e),a>=0&&N.splice(a,1)}function u(t,a){var r=this;a&&a.obj&&(r=a.obj,r.validatorAttrs=a.obj.attrs);var i=a&&a.elm?a.elm:r.elm,n=i&&i.attr("name")?i.attr("name"):null;if("undefined"==typeof n||null===n)throw'Angular-Validation Service requires you to have a (name="") attribute on the element to validate... Your element is: ng-model="'+i.attr("ng-model")+'"';var s=a&&a.translate?e.instant(t):t,l=n.replace(/[|&;$%@"<>()+,\[\]\{\}]/g,""),o=null;if(r.validatorAttrs&&r.validatorAttrs.hasOwnProperty("validationErrorTo")){var d=r.validatorAttrs.validationErrorTo.charAt(0),u="."===d||"#"===d?r.validatorAttrs.validationErrorTo:"#"+r.validatorAttrs.validationErrorTo;o=angular.element(document.querySelector(u))}o&&0!==o.length||(o=angular.element(document.querySelector(".validation-"+l)));var p=a&&a.isSubmitted?a.isSubmitted:!1;a&&!a.isValid&&(p||r.ctrl.$dirty||r.ctrl.$touched)?o.length>0?o.text(s):i.after(''+s+""):o.text("")}function p(t,a){for(var r,n,s=this,l=!0,o=!0,d="",u=s.validatorAttrs&&s.validatorAttrs.name?s.validatorAttrs.name:s.attrs&&s.attrs.name?s.attrs.name:s.elm.attr("name"),p=i(u),m=s.validatorAttrs.hasOwnProperty("rules")?s.validatorAttrs.rules:s.validatorAttrs.validation,g=0,f=s.validators.length;f>g;g++){if(n=s.validators[g],"conditionalDate"===n.type){if(r=new RegExp(n.pattern,"i"),l="\\S+"!==n.pattern||"undefined"!=typeof t&&null!==t?r.test(t):!1){var h=n.dateType,b=y(t,h).getTime();if(2==n.params.length){var A=y(n.params[0],h).getTime(),x=y(n.params[1],h).getTime(),R=E(n.condition[0],b,A),N=E(n.condition[1],b,x);l=R&&N?!0:!1}else{var S=y(n.params[0],h).getTime();l=E(n.condition,b,S)}}}else if("conditionalNumber"===n.type)if(2==n.params.length){var R=E(n.condition[0],parseFloat(t),parseFloat(n.params[0])),N=E(n.condition[1],parseFloat(t),parseFloat(n.params[1]));l=R&&N?!0:!1}else l=E(n.condition,parseFloat(t),parseFloat(n.params[0]));else if("match"===n.type){var T=n.params[0],w=s.scope.$eval(T);l=w===t}else s.elm.prop("disabled")||1==parseInt(s.elm.attr("ng-disabled"))||"true"===s.elm.attr("ng-disabled")?l=!0:"string"==typeof t&&""===t&&"NUMBER"===s.elm.prop("type").toUpperCase()?(l=!1,d=e.instant("INVALID_KEY_CHAR")):(r=new RegExp(n.pattern,"i"),l=!("\\S+"===n.pattern||m&&m.indexOf("required")>=0)||"undefined"!=typeof t&&null!==t?r.test(t):!1);(!s.bFieldRequired&&!t||s.elm.prop("disabled")||1==parseInt(s.elm.attr("ng-disabled"))||"true"===s.elm.attr("ng-disabled"))&&(l=!0),l||(o=!1,function(t,r,i){var n=i.message;i.altText&&i.altText.length>0&&(n=i.altText.replace("alt=","")),e(n).then(function(e){d+=" "+O(i,e),c(s,t,d,o,a)})["catch"](function(){i.altText&&i.altText.length>0&&(d+=" "+n,c(s,t,d,o,a))})}(p,l,n))}return l&&(v(s,""),s.updateErrorMsg("",{isValid:l})),p&&(p.isValid=o,o&&(p.message="")),o}function m(t,a,r,i){var n=a.name?a.name:t.attr("name"),s=a&&a.friendlyName?e.instant(a.friendlyName):"",l={fieldName:n,friendlyName:s,elm:t,attrs:a,ctrl:r,scope:i,isValid:!1,message:""},o=h(R,"fieldName",t.attr("name"));return o>=0?R[o]=l:R.push(l),R}function c(t,e,a,r,i){a=a.trim(),v(e,a),e&&(e.message=a),i&&!e.isValid?t.updateErrorMsg(a,{isValid:r}):e&&e.isValid&&v(e,"")}function v(t,a){var r=t.validatorAttrs&&t.validatorAttrs.name?t.validatorAttrs.name:t.attrs&&t.attrs.name?t.attrs.name:t.elm.attr("name"),i=b(r,t),n=h(N,"field",r);if(n>=0&&""===a)N.splice(n,1);else if(""!==a){var s=t.attrs&&t.friendlyName?e.instant(t.friendlyName):"",l={field:r,friendlyName:s,message:a,formName:i?i.$name:null};n>=0?N[n]=l:N.push(l)}return t.scope.$validationSummary=N,i&&(i.$validationSummary=f(N,"formName",i.$name)),N}function g(t,e,a){for(var r=0;r8?t.substring(9).split(":"):null;break;case"UK":case"EURO":case"EURO_SHORT":case"EURO-SHORT":case"EUROPE":a=t.substring(0,8),r=t.substring(2,3),i=A(a,r),o=i[0],l=i[1],s=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=t.length>8?t.substring(9).split(":"):null;break;case"US_LONG":case"US-LONG":a=t.substring(0,10),r=t.substring(2,3),i=A(a,r),l=i[0],o=i[1],s=i[2],n=t.length>8?t.substring(9).split(":"):null;break;case"US":case"US_SHORT":case"US-SHORT":a=t.substring(0,8),r=t.substring(2,3),i=A(a,r),l=i[0],o=i[1],s=parseInt(i[2])<50?"20"+i[2]:"19"+i[2],n=t.length>8?t.substring(9).split(":"):null;break;case"ISO":default:a=t.substring(0,10),r=t.substring(4,5),i=A(a,r),s=i[0],l=i[1],o=i[2],n=t.length>10?t.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(s,l-1,o,d,u,p)}function O(t,e){if(t&&t.params)for(var a=0,r=t.params.length;r>a;a++)"match"===t.type&&r>1&&0===a||(e=e.replace(":param",t.params[a]));return e}function A(t,e){var a=[];switch(e){case"/":a=t.split("/");break;case".":a=t.split(".");break;case"-":default:a=t.split("-")}return a}function E(t,e,a){var r=!1;switch(t){case"<":r=a>e?!0:!1;break;case"<=":r=a>=e?!0:!1;break;case">":r=e>a?!0:!1;break;case">=":r=e>=a?!0:!1;break;case"!=":case"<>":r=e!=a?!0:!1;break;case"=":case"==":r=e==a?!0:!1;break;default:r=!1}return r}var x=1e3,R=[],N=[],S=function(t,e,a,r){this.timer=null,this.bFieldRequired=!1,this.validators=[],this.typingLimit=x,this.scope=t,this.elm=e,this.ctrl=r,this.validatorAttrs=a,t&&e&&a&&r&&(m(e,a,r,t),this.defineValidation())};return S.prototype.defineValidation=r,S.prototype.getFormElementByName=i,S.prototype.getFormElements=n,S.prototype.isFieldRequired=l,S.prototype.initialize=s,S.prototype.updateErrorMsg=u,S.prototype.validate=p,S.prototype.removeFromValidationSummary=d,S.prototype.removeFromFormElementObjectList=o,S}]); angular.module("ghiscoding.validation").factory("validationRules",[function(){function e(e){var a="undefined"!=typeof e.altText?e.altText.replace("alt=",""):null,t=e.hasOwnProperty("customRegEx")?e.customRegEx:null,s=e.hasOwnProperty("rule")?e.rule:null,r=e.hasOwnProperty("ruleParams")?e.ruleParams:null,n={};switch(s){case"alpha":n={pattern:"^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$",message:"INVALID_ALPHA",type:"regex"};break;case"alphaSpaces":case"alpha_spaces":n={pattern:"^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\\s])+$",message:"INVALID_ALPHA_SPACE",type:"regex"};break;case"alphaNum":case"alpha_num":n={pattern:"^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$",message:"INVALID_ALPHA_NUM",type:"regex"};break;case"alphaNumSpaces":case"alpha_num_spaces":n={pattern:"^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\\s])+$",message:"INVALID_ALPHA_NUM_SPACE",type:"regex"};break;case"alphaDash":case"alpha_dash":n={pattern:"^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ_-])+$",message:"INVALID_ALPHA_DASH",type:"regex"};break;case"alphaDashSpaces":case"alpha_dash_spaces":n={pattern:"^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\\s_-])+$",message:"INVALID_ALPHA_DASH_SPACE",type:"regex"};break;case"betweenLen":case"between_len":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_len:1,5";n={pattern:"^.{"+_[0]+","+_[1]+"}$",message:"INVALID_BETWEEN_CHAR",params:[_[0],_[1]],type:"regex"};break;case"betweenNum":case"between_num":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_num:1,5";n={condition:[">=","<="],message:"INVALID_BETWEEN_NUM",params:[_[0],_[1]],type:"conditionalNumber"};break;case"creditCard":case"credit_card":n={pattern:"^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|6(?:011|5[0-9]{2})[0-9]{12}|(?:2131|1800|35\\d{3})\\d{11})$",message:"INVALID_CREDIT_CARD",type:"regex"};break;case"dateEuroLong":case"date_euro_long":n={pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/](19|20)\\d\\d$",message:"INVALID_DATE_EURO_LONG",type:"regex"};break;case"dateEuroLongBetween":case"date_euro_long_between":case"betweenDateEuroLong":case"between_date_euro_long":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_long:01-01-1990,31-12-2015";n={condition:[">=","<="],dateType:"EURO_LONG",params:[_[0],_[1]],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/](19|20)\\d\\d$",message:"INVALID_DATE_EURO_LONG_BETWEEN",type:"conditionalDate"};break;case"dateEuroLongMax":case"date_euro_long_max":case"maxDateEuroLong":case"max_date_euro_long":n={condition:"<=",dateType:"EURO_LONG",params:[r],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/](19|20)\\d\\d$",message:"INVALID_DATE_EURO_LONG_MAX",type:"conditionalDate"};break;case"dateEuroLongMin":case"date_euro_long_min":case"minDateEuroLong":case"min_date_euro_long":n={condition:">=",dateType:"EURO_LONG",params:[r],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/](19|20)\\d\\d$",message:"INVALID_DATE_EURO_LONG_MIN",type:"conditionalDate"};break;case"dateEuroShort":case"date_euro_short":n={pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/]\\d\\d$",message:"INVALID_DATE_EURO_SHORT",type:"regex"};break;case"dateEuroShortBetween":case"date_euro_short_between":case"betweenDateEuroShort":case"between_date_euro_short":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_euro_short:01-01-90,31-12-15";n={condition:[">=","<="],dateType:"EURO_SHORT",params:[_[0],_[1]],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/]\\d\\d$",message:"INVALID_DATE_EURO_SHORT_BETWEEN",type:"conditionalDate"};break;case"dateEuroShortMax":case"date_euro_short_max":case"maxDateEuroShort":case"max_date_euro_short":n={condition:"<=",dateType:"EURO_SHORT",params:[r],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/]\\d\\d$",message:"INVALID_DATE_EURO_SHORT_MAX",type:"conditionalDate"};break;case"dateEuroShortMin":case"date_euro_short_min":case"minDateEuroShort":case"min_date_euro_short":n={condition:">=",dateType:"EURO_SHORT",params:[r],pattern:"^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[012])[-/]\\d\\d$",message:"INVALID_DATE_EURO_SHORT_MIN",type:"conditionalDate"};break;case"dateIso":case"date_iso":n={pattern:"^(19|20)\\d\\d([-])(0[1-9]|1[012])\\2(0[1-9]|[12][0-9]|3[01])$",message:"INVALID_DATE_ISO",type:"regex"};break;case"dateIsoBetween":case"date_iso_between":case"betweenDateIso":case"between_date_iso":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_iso:1990-01-01,2000-12-31";n={condition:[">=","<="],dateType:"ISO",params:[_[0],_[1]],pattern:"^(19|20)\\d\\d([-])(0[1-9]|1[012])\\2(0[1-9]|[12][0-9]|3[01])$",message:"INVALID_DATE_ISO_BETWEEN",type:"conditionalDate"};break;case"dateIsoMax":case"date_iso_max":case"maxDateIso":case"max_date_iso":n={condition:"<=",dateType:"ISO",params:[r],pattern:"^(19|20)\\d\\d([-])(0[1-9]|1[012])\\2(0[1-9]|[12][0-9]|3[01])$",message:"INVALID_DATE_ISO_MAX",type:"conditionalDate"};break;case"dateIsoMin":case"date_iso_min":case"minDateIso":case"min_date_iso":n={condition:">=",dateType:"ISO",params:[r],pattern:"^(19|20)\\d\\d([-])(0[1-9]|1[012])\\2(0[1-9]|[12][0-9]|3[01])$",message:"INVALID_DATE_ISO_MIN",type:"conditionalDate"};break;case"dateUsLong":case"date_us_long":n={pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/](19|20)\\d\\d$",message:"INVALID_DATE_US_LONG",type:"regex"};break;case"dateUsLongBetween":case"date_us_long_between":case"betweenDateUsLong":case"between_date_us_long":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_long:01/01/1990,12/31/2015";n={condition:[">=","<="],dateType:"US_LONG",params:[_[0],_[1]],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/](19|20)\\d\\d$",message:"INVALID_DATE_US_LONG_BETWEEN",type:"conditionalDate"};break;case"dateUsLongMax":case"date_us_long_max":case"maxDateUsLong":case"max_date_us_long":n={condition:"<=",dateType:"US_LONG",params:[r],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/](19|20)\\d\\d$",message:"INVALID_DATE_US_LONG_MAX",type:"conditionalDate"};break;case"dateUsLongMin":case"date_us_long_min":case"minDateUsLong":case"min_date_us_long":n={condition:">=",dateType:"US_LONG",params:[r],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/](19|20)\\d\\d$",message:"INVALID_DATE_US_LONG_MIN",type:"conditionalDate"};break;case"dateUsShort":case"date_us_short":n={pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/]\\d\\d$",message:"INVALID_DATE_US_SHORT",type:"regex"};break;case"dateUsShortBetween":case"date_us_short_between":case"betweenDateUsShort":case"between_date_us_short":var _=r.split(",");if(2!==_.length)throw"This validation must include exactly 2 params separated by a comma (,) ex.: between_date_us_short:01/01/90,12/31/15";n={condition:[">=","<="],dateType:"US_SHORT",params:[_[0],_[1]],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/]\\d\\d$",message:"INVALID_DATE_US_SHORT_BETWEEN",type:"conditionalDate"};break;case"dateUsShortMax":case"date_us_short_max":case"maxDateUsShort":case"max_date_us_short":n={condition:"<=",dateType:"US_SHORT",params:[r],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/]\\d\\d$",message:"INVALID_DATE_US_SHORT_MAX",type:"conditionalDate"};break;case"dateUsShortMin":case"date_us_short_min":case"minDateUsShort":case"min_date_us_short":n={condition:">=",dateType:"US_SHORT",params:[r],pattern:"^(0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])[-/]\\d\\d$",message:"INVALID_DATE_US_SHORT_MIN",type:"conditionalDate"};break;case"email":n={pattern:"^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$",message:"INVALID_EMAIL",type:"regex"};break;case"exactLen":case"exact_len":n={pattern:"^.{"+r+"}$",message:"INVALID_EXACT_LEN",params:[r],type:"regex"};break;case"float":n={pattern:"^\\d*\\.{1}\\d+$",message:"INVALID_FLOAT",type:"regex"};break;case"floatSigned":case"float_signed":n={pattern:"^[-+]?\\d*\\.{1}\\d+$",message:"INVALID_FLOAT_SIGNED",type:"regex"};break;case"iban":n={pattern:"[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}",message:"INVALID_IBAN",type:"regex"};break;case"int":case"integer":n={pattern:"^\\d+$",message:"INVALID_INTEGER",type:"regex"};break;case"intSigned":case"integerSigned":case"int_signed":case"integer_signed":n={pattern:"^[+-]?\\d+$",message:"INVALID_INTEGER_SIGNED",type:"regex"};break;case"ipv4":n={pattern:"^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$",message:"INVALID_IPV4",type:"regex"};break;case"ipv6":n={pattern:"^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$",message:"INVALID_IPV6",type:"regex"};break;case"ipv6_hex":n={pattern:"^((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)$",message:"INVALID_IPV6_HEX",type:"regex"};break;case"match":var e=r.split(",");n={message:"INVALID_INPUT_MATCH",params:e,type:"match"};break;case"maxLen":case"max_len":n={pattern:"^.{0,"+r+"}$",message:"INVALID_MAX_CHAR",params:[r],type:"regex"};break;case"maxNum":case"max_num":n={condition:"<=",message:"INVALID_MAX_NUM",params:[r],type:"conditionalNumber"};break;case"minLen":case"min_len":n={pattern:"^.{"+r+",}$",message:"INVALID_MIN_CHAR",params:[r],type:"regex"};break;case"minNum":case"min_num":n={condition:">=",message:"INVALID_MIN_NUM",params:[r],type:"conditionalNumber"};break;case"numeric":n={pattern:"^\\d*\\.?\\d+$",message:"INVALID_NUMERIC",type:"regex"};break;case"numericSigned":case"numeric_signed":n={pattern:"^[-+]?\\d*\\.?\\d+$",message:"INVALID_NUMERIC_SIGNED",type:"regex"};break;case"regex":n={pattern:t.pattern,message:"INVALID_PATTERN",params:[t.message],type:"regex"};break;case"required":n={pattern:"\\S+",message:"INVALID_REQUIRED",type:"regex"};break;case"url":n={pattern:"(http|ftp|https):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?",message:"INVALID_URL",type:"regex"};break;case"time":n={pattern:"^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$",message:"INVALID_TIME",type:"regex"};break;case"checked":n={pattern:"^true$",message:"INVALID_CHECKBOX_SELECTED",type:"regex"}}return n.altText=a,n}var a={getElementValidators:e};return a}]); -angular.module("ghiscoding.validation").service("validationService",["$timeout","validationCommon",function(e,o){function t(o,t){var i=this,n={};if("string"==typeof o&&"string"==typeof t?(n.elmName=o,n.rules=t):n=o,"object"!=typeof n||!n.hasOwnProperty("elmName")||!n.hasOwnProperty("rules")||!n.hasOwnProperty("scope")&&"undefined"==typeof i.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";return n.elm=angular.element(document.querySelector('[name="'+n.elmName+'"]:not([disabled]):not([ng-disabled]')),"object"!=typeof n.elm||0===n.elm.length?i:(new RegExp("{{(.*?)}}").test(n.elmName)&&(n.elmName=$interpolate(n.elmName)(n.scope)),n.name=n.elmName,n.elm.bind("blur",s=function(e){u||(i.commonObj.initialize(n.scope,n.elm,n,n.ctrl),i.commonObj.typingLimit=0,r(i,e.target.value))}),n=c(i.validationAttrs,n),n.scope.$watch(n.elmName,function(o,t){return void 0===o&&void 0!==t?(e.cancel(i.timer),void i.commonObj.ctrl.$setValidity("validation",i.commonObj.validate("",!0))):(n.ctrl=angular.element(n.elm).controller("ngModel"),n.value=o,i.commonObj.initialize(n.scope,n.elm,n,n.ctrl),void r(i,o))},!0),i)}function i(e){var o=this,t="",i=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope object passed as argument to function properly (ex.: $scope.form1 OR $scope).";for(var n=0,a=e.$validationSummary.length;a>n;n++)if(i=!1,t=e.$validationSummary[n].field){var m=o.commonObj.getFormElementByName(t);m.elm&&m.elm.length>0&&(m.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:m.isValid,obj:m}))}return i}function n(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope object passed as argument to function properly (ex.: $scope.form1 OR $scope).";for(var t=[],i=0,n=e.$validationSummary.length;n>i;i++)t.push(e.$validationSummary[i].field);for(i=0,n=t.length;n>i;i++)t[i]&&(o.commonObj.removeFromFormElementObjectList(t[i]),o.commonObj.removeFromValidationSummary(e.$validationSummary,t[i]))}function a(e,o){var t,i=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope object passed as argument to function properly (ex.: $scope.form1 OR $scope).";if(o instanceof Array)for(var n=0,a=o.length;a>n;n++)t=i.commonObj.getFormElementByName(o[n]),d(i,t,e.$validationSummary);else t=i.commonObj.getFormElementByName(o),d(i,t,e.$validationSummary);return i}function m(e){var o=this;return o.validationAttrs=e,o}function r(o,t){return o.commonObj.validate(t,!1),o.commonObj.isFieldRequired()||""!==t&&null!==t&&"undefined"!=typeof t?(u=!1,(o.commonObj.isFieldRequired()||t)&&o.commonObj.ctrl.$setValidity("validation",!1),""!==t&&"undefined"!=typeof t||"NUMBER"!==o.commonObj.elm.prop("type").toUpperCase()?"SELECT"===o.commonObj.elm.prop("tagName").toUpperCase()?(o.commonObj.ctrl.$setValidity("validation",o.commonObj.validate(t,!0)),t):("undefined"!=typeof t&&(o.commonObj.updateErrorMsg(""),e.cancel(o.timer),o.timer=e(function(){o.commonObj.scope.$evalAsync(o.commonObj.ctrl.$setValidity("validation",o.commonObj.validate(t,!0)))},o.commonObj.typingLimit)),t):(e.cancel(o.timer),o.commonObj.ctrl.$setValidity("validation",o.commonObj.validate(t,!0)),t)):(l(o),t)}function l(o){u=!0,e.cancel(self.timer),o.commonObj.updateErrorMsg(""),o.commonObj.ctrl.$setValidity("validation",!0),"undefined"!=typeof s&&o.commonObj.elm.unbind("blur",s)}function c(e,o){var t={};for(var i in e)t[i]=e[i];for(var i in o)t[i]=o[i];return t}function d(e,o,t){if("undefined"!=typeof e.commonObj.scope){var i=e.commonObj.scope.$watch(o.fieldName,function(){});i(),o.ctrl.$setUntouched(),o.ctrl.$setPristine(),o.ctrl.$setValidity("validation",!0),e.commonObj.removeFromValidationSummary(t,o.fieldName),e.commonObj.updateErrorMsg("",{isValid:!0,obj:o})}}var s,u=!1,p=function(){this.validationAttrs={},this.commonObj=new o};return p.prototype.addValidator=t,p.prototype.checkFormValidity=i,p.prototype.removeValidator=a,p.prototype.setGlobalOptions=m,p.prototype.clearInvalidValidatorsInSummary=n,p}]); \ No newline at end of file +angular.module("ghiscoding.validation").service("validationService",["$timeout","validationCommon",function(e,o){function t(o,t,i){var n=this,a={};if("string"==typeof o&&"string"==typeof t?(a.elmName=o,a.rules=t,a.friendlyName="string"==typeof i?i:""):a=o,"object"!=typeof a||!a.hasOwnProperty("elmName")||!a.hasOwnProperty("rules")||!a.hasOwnProperty("scope")&&"undefined"==typeof n.validationAttrs.scope)throw"Angular-Validation-Service requires at least the following 3 attributes: {elmName, rules, scope}";return a.elm=angular.element(document.querySelector('[name="'+a.elmName+'"]:not([disabled]):not([ng-disabled]')),"object"!=typeof a.elm||0===a.elm.length?n:(new RegExp("{{(.*?)}}").test(a.elmName)&&(a.elmName=$interpolate(a.elmName)(a.scope)),a.name=a.elmName,a.elm.bind("blur",s=function(e){u||(n.commonObj.initialize(a.scope,a.elm,a,a.ctrl),n.commonObj.typingLimit=0,r(n,e.target.value))}),a=c(n.validationAttrs,a),a.scope.$watch(a.elmName,function(o,t){return void 0===o&&void 0!==t?(e.cancel(n.timer),void n.commonObj.ctrl.$setValidity("validation",n.commonObj.validate("",!0))):(a.ctrl=angular.element(a.elm).controller("ngModel"),a.value=o,n.commonObj.initialize(a.scope,a.elm,a,a.ctrl),void r(n,o))},!0),n)}function i(e){var o=this,t="",i=!0;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope object passed as argument to function properly (ex.: $scope.form1 OR $scope).";for(var n=0,a=e.$validationSummary.length;a>n;n++)if(i=!1,t=e.$validationSummary[n].field){var m=o.commonObj.getFormElementByName(t);m.elm&&m.elm.length>0&&(m.ctrl.$setTouched(),o.commonObj.updateErrorMsg(e.$validationSummary[n].message,{isSubmitted:!0,isValid:m.isValid,obj:m}))}return i}function n(e){var o=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope object passed as argument to function properly (ex.: $scope.form1 OR $scope).";for(var t=[],i=0,n=e.$validationSummary.length;n>i;i++)t.push(e.$validationSummary[i].field);for(i=0,n=t.length;n>i;i++)t[i]&&(o.commonObj.removeFromFormElementObjectList(t[i]),o.commonObj.removeFromValidationSummary(e.$validationSummary,t[i]))}function a(e,o){var t,i=this;if("undefined"==typeof e||"undefined"==typeof e.$validationSummary)throw"checkFormValidity() requires a valid Angular Form or $scope object passed as argument to function properly (ex.: $scope.form1 OR $scope).";if(o instanceof Array)for(var n=0,a=o.length;a>n;n++)t=i.commonObj.getFormElementByName(o[n]),d(i,t,e.$validationSummary);else t=i.commonObj.getFormElementByName(o),d(i,t,e.$validationSummary);return i}function m(e){var o=this;return o.validationAttrs=e,o}function r(o,t){return o.commonObj.validate(t,!1),o.commonObj.isFieldRequired()||""!==t&&null!==t&&"undefined"!=typeof t?(u=!1,(o.commonObj.isFieldRequired()||t)&&o.commonObj.ctrl.$setValidity("validation",!1),""!==t&&"undefined"!=typeof t||"NUMBER"!==o.commonObj.elm.prop("type").toUpperCase()?"SELECT"===o.commonObj.elm.prop("tagName").toUpperCase()?(o.commonObj.ctrl.$setValidity("validation",o.commonObj.validate(t,!0)),t):("undefined"!=typeof t&&(o.commonObj.updateErrorMsg(""),e.cancel(o.timer),o.timer=e(function(){o.commonObj.scope.$evalAsync(o.commonObj.ctrl.$setValidity("validation",o.commonObj.validate(t,!0)))},o.commonObj.typingLimit)),t):(e.cancel(o.timer),o.commonObj.ctrl.$setValidity("validation",o.commonObj.validate(t,!0)),t)):(l(o),t)}function l(o){u=!0,e.cancel(self.timer),o.commonObj.updateErrorMsg(""),o.commonObj.ctrl.$setValidity("validation",!0),"undefined"!=typeof s&&o.commonObj.elm.unbind("blur",s)}function c(e,o){var t={};for(var i in e)t[i]=e[i];for(var i in o)t[i]=o[i];return t}function d(e,o,t){if("undefined"!=typeof e.commonObj.scope){var i=e.commonObj.scope.$watch(o.fieldName,function(){});i(),o.ctrl.$setUntouched(),o.ctrl.$setPristine(),o.ctrl.$setValidity("validation",!0),e.commonObj.removeFromValidationSummary(t,o.fieldName),e.commonObj.updateErrorMsg("",{isValid:!0,obj:o})}}var s,u=!1,p=function(){this.validationAttrs={},this.commonObj=new o};return p.prototype.addValidator=t,p.prototype.checkFormValidity=i,p.prototype.removeValidator=a,p.prototype.setGlobalOptions=m,p.prototype.clearInvalidValidatorsInSummary=n,p}]); \ No newline at end of file diff --git a/locales/validation/en.json b/locales/validation/en.json index 3f0015b..abbf0cb 100644 --- a/locales/validation/en.json +++ b/locales/validation/en.json @@ -74,6 +74,8 @@ "INPUT17": "Alphanumeric + Exactly(3) + Required -- debounce(5sec)", "INPUT18": "Date ISO (yyyy-mm-dd) -- minimum condition >= 2001-01-01 ", "INPUT19": "Date US SHORT (mm/dd/yy) -- between the dates 12/01/99 and 12/31/15", + "FIRST_NAME": "First Name", + "LAST_NAME": "Last Name", "SAVE": "Save", "SELECT1": "Required (select) -- validation with (blur) EVENT", "SHOW_VALIDATION_SUMMARY": "Show Validation Summary" diff --git a/locales/validation/es.json b/locales/validation/es.json index 4764a14..9ee40f0 100644 --- a/locales/validation/es.json +++ b/locales/validation/es.json @@ -74,6 +74,8 @@ "INPUT17": "Alfanúmerico + Exactamente(3) + Requerido -- debounce(5sec)", "INPUT18": "Fecha formato ISO (yyyy-mm-dd) -- Condición minima >= 2001-01-01 ", "INPUT19": "Fecha formato US corto (mm/dd/yy) -- entre las fechas 12/01/99 and 12/31/15", + "FIRST_NAME": "Nombre", + "LAST_NAME": "Apellido", "SAVE": "Guardar", "SELECT1": "Requerido (select) -- validación con (blur) EVENT", "SHOW_VALIDATION_SUMMARY": "Mostar el resumén de validación" diff --git a/locales/validation/fr.json b/locales/validation/fr.json index 447a1ca..4643588 100644 --- a/locales/validation/fr.json +++ b/locales/validation/fr.json @@ -74,6 +74,8 @@ "INPUT17": "Alphanumérique + Exactement(3) + Requis -- debounce(5sec)", "INPUT18": "Date ISO (yyyy-mm-dd ) -- condition minimal >= 2001-01-01 ", "INPUT19": "Date US COURT (mm/dd/yy) -- entre les dates 12/01/99 et 12/31/15", + "FIRST_NAME": "Prénom", + "LAST_NAME": "Nom de Famille", "SAVE": "Sauvegarder", "SELECT1": "Requis (select) -- validation avec EVENT (blur)", "SHOW_VALIDATION_SUMMARY": "Afficher le Résumé de Validation" diff --git a/locales/validation/no.json b/locales/validation/no.json index 4fd4e5e..dd6facb 100644 --- a/locales/validation/no.json +++ b/locales/validation/no.json @@ -74,6 +74,8 @@ "INPUT17": "Alfanumerisk + Nøyaktig(3) + Påkrevd -- debounce(5sec)", "INPUT18": "ISO dato (yyyy-mm-dd) -- minimum >= 2001-01-01 ", "INPUT19": "US SHORT dato (mm/dd/yy) -- mellom 12/01/99 og 12/31/15", + "FIRST_NAME": "Fornavn", + "LAST_NAME": "Etternavn", "SAVE": "Lagre", "SELECT1": "Påkrevd (select) -- validering med (blur) EVENT", "SHOW_VALIDATION_SUMMARY": "Vis Valideringsoppsummering" diff --git a/locales/validation/ru.json b/locales/validation/ru.json index dcc63a6..3753dde 100644 --- a/locales/validation/ru.json +++ b/locales/validation/ru.json @@ -74,6 +74,8 @@ "INPUT17": "Буквенно-цифровой + Точно(3) + Обязательно -- debounce(5sec)", "INPUT18": "Дата ISO (yyyy-mm-dd) -- минимальное условие >= 2001-01-01 ", "INPUT19": "Дата US SHORT (mm/dd/yy) --между датами 12/01/99 и 12/31/15", + "FIRST_NAME": "Имя", + "LAST_NAME": "Фамилия", "SAVE": "Сохранить", "SELECT1": "Обязательное (select) -- проверка по СОБЫТИЮ (blur)", "SHOW_VALIDATION_SUMMARY": "Показать результаты проверки значений" diff --git a/package.json b/package.json index 7e54d88..69fdc46 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-validation-ghiscoding", - "version": "1.3.21", + "version": "1.3.22", "author": "Ghislain B.", "description": "Angular-Validation Directive and Service (ghiscoding)", "main": "app.js", diff --git a/readme.md b/readme.md index 898563e..2a692e0 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ #Angular Validation (Directive / Service) -`Version: 1.3.21` +`Version: 1.3.22` ### Form validation after user inactivity of default 1sec. (customizable timeout) Forms Validation with Angular made easy! Angular-Validation is an angular directive/service with locales (languages) with a very simple approach of defining your `validation=""` directly within your element to validate (input, textarea, etc) and...that's it!!! The directive/service will take care of the rest! @@ -8,15 +8,16 @@ The base concept is not new, it comes from the easy form input validation approa For a smoother user experience, I also added validation on inactivity (timer/debounce). So validation will not bother the user while he is still typing... though as soon as the user pauses for a certain amount of time, then validation comes into play. It's worth knowing that this inactivity timer is only available while typing, if user focuses away from his input (onBlur) it will then validate instantly. -Supporting AngularJS 1.3.x -*current code should work with 1.2.x just the same but is no more verified* +Supporting AngularJS 1.3.x *(current code should work with 1.2.x just the same but is no more verified)* -Now support Service using the same functionality as the Directive. -Huge rewrite to have a better code separation and also adding support to Service functionality. Specifically the `validation-rules` was separated to add rules without affecting the core while `validation-common` is for shared functions (shared by Directive/Service). +Now support Service using the same functionalities as the Directive. +Huge rewrite to have a better code separation and also adding support to Service functionalities. Specifically the `validation-rules` was separated to add rules without affecting the core while `validation-common` is for shared functions (shared by Directive/Service). [Validation summary](#validation-summary) was also recently added to easily show all validation errors that are still active on the form and you can also use 2 ways of dealing with the [Submit](#submit) button. -For more explanations, see the question answered: [Why Use It?](#whyuseit) +For more reasons to use it, see the answered question of: [Why Use It?](#whyuseit) + +If you do use it, please click on the Star and add it as a favourite. The more star ratings there is, the more chances it could found by other users as a populate trend. That is the only support I ask you... thanks ;) ## Live Demo @@ -32,7 +33,7 @@ For more explanations, see the question answered: [Why Use It?](#whyuseit) * [Dependencies](#dependencies) * [Form Submit and Validation - checkFormValidity()](#submit) * [Global Options](#global-options) -* [Install (bower)](#install) +* [Install (Bower/NuGet)](#install) * [Include it in your app project](#project) * [License](#license) * [Locales (languages)](#locales) @@ -46,7 +47,7 @@ For more explanations, see the question answered: [Why Use It?](#whyuseit) Why use angular-validation? ----- -Angular-validation was develop with DRY (Don't Repeat Yourself) and simplicity in mind. +Angular-validation was develop with simplicity and DRY (Don't Repeat Yourself) concept in mind. You can transform this: ```html ``` -The Angular-Validation will create by itself the necessary error message. Now imagine your form with 10 inputs, using the Angular-Validation will end up using 10 lines of code, while on the other hand using the default of Angular will give you 30 lines of code... so what are you waiting for? Use Angular-Validation!!! :) +The Angular-Validation will create, by itself, the necessary error message. Now imagine your form with 10 inputs, using the Angular-Validation will end up using 10 lines of code, while on the other hand using the default of Angular will give you 30 lines of code... so what are you waiting for? Use Angular-Validation!!! :) Let's not forget the [Validation summary](#validation-summary) which is also a great and useful way of displaying your errors to the user. @@ -74,16 +75,26 @@ Install with Bower // You can install with bower install angular-validation-ghiscoding -// or as another name +// or as another alias bower install ghiscoding.angular-validation ``` +Install with NuGet (see the [NuGet Package Here](http://www.nuget.org/packages/Angular-Validation-Ghiscoding)) +```javascript +PM> Install-Package Angular-Validation-Ghiscoding +``` +When used with IIS, you will need to map the JSON type +```html + + + +``` Include it in your app project -------------------- The angular-validation scripts are now available in 2 formats: uncompressed (`src/*.js`) or minified (`dist/angular-validation.min.js`). The minified script englobes all uncompressed scripts. Also note that `angular-translate` (3rd party app) is also a [dependency](#dependencies). -*If you use the uncompressed scripts, it is worth to know that the Directive and/or Service are totally independent and could be called together or separately BUT you will still need the `validation-rules` and `validation-common` files.* +*If you use the uncompressed scripts, it is worth to know that the Directive and/or Service are totally independent and could be called together or separately BUT you will still need the `validation-common` and `validation-rules` files.* ```javascript // include it your app module ( we need both Translate & Validation) var myApp = angular.module('myApp', ['ngRoute', 'ghiscoding.validation', 'pascalprecht.translate']); @@ -97,7 +108,7 @@ myApp.config(function ($translateProvider) { suffix: '.json' }); - // load English ('en') table on startup + // define translation maps you want to use on startup $translateProvider.preferredLanguage('en'); }); ``` @@ -126,23 +137,28 @@ Let's start with a simple example and then let's get down to real business. P.S. For real live sample, see the [live plunker demo](#plunker) or download the Github project and run the `index.html` (on the exception of Chrome who doesn't want to run http outside of webserver) while the actual form with validation is inside `templates/testingFormDirective.html` for a better separation. -*To define the debounce globally (for all form elements), you could use `$scope.$validationOptions = { debounce: 1500 };` or set it on each element `* +*To define the debounce globally (for all form elements), you could use `$scope.$validationOptions = { debounce: 1500 };` or set it independently on each element ``* ```html + + + + - + - + - + @@ -151,12 +167,12 @@ P.S. For real live sample, see the [live plunker demo](#plunker) or download the - + - +
+ +
- - + +
@@ -40,7 +40,7 @@

{{ 'ERRORS' | translate }}!

{{ 'ERRORS' | translate }}!

diff --git a/templates/testingFormDirective.html b/templates/testingFormDirective.html index f5b4f71..a5c572b 100644 --- a/templates/testingFormDirective.html +++ b/templates/testingFormDirective.html @@ -11,7 +11,7 @@

Directive

{{ 'ERRORS' | translate }}!

    -
  • {{item.field }}: {{item.message}}
  • +
  • {{ item.friendlyName != '' ? item.friendlyName : item.field }}: {{item.message}}
@@ -31,7 +31,7 @@

{{ 'ERRORS' | translate }}!

- +
@@ -39,11 +39,11 @@

{{ 'ERRORS' | translate }}!

- +
- +
diff --git a/templates/testingFormService.html b/templates/testingFormService.html index e5eee55..0da4c95 100644 --- a/templates/testingFormService.html +++ b/templates/testingFormService.html @@ -16,7 +16,7 @@

Service

{{ 'ERRORS' | translate }}!

    -
  • {{item.field }}: {{item.message}}
  • +
  • {{ item.friendlyName != '' ? item.friendlyName : item.field }}: {{item.message}}