{"size": 7397, "ext": "js", "max_stars_repo_path": "dist/srvalidator.min.js", "max_stars_repo_name": "rummykhan/r-validator", "max_stars_repo_stars_event_min_datetime": "2017-08-15T09:05:12.000Z", "max_stars_repo_stars_event_max_datetime": "2018-01-04T12:01:26.000Z", "max_issues_repo_path": "dist/srvalidator.min.js", "max_issues_repo_name": "rummykhan/r-validator", "max_issues_repo_issues_event_min_datetime": "2017-06-21T13:36:22.000Z", "max_issues_repo_issues_event_max_datetime": "2017-06-21T13:36:22.000Z", "max_forks_repo_path": "dist/srvalidator.min.js", "max_forks_repo_name": "rummykhan/r-validator", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 7397.0, "max_line_length": 7397, "alphanum_fraction": 0.6875760443}
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.srvalidator=e()}(this,function(){"use strict";var t=function(t,e){return e={exports:{}},t(e,e.exports),e.exports}(function(t){!function(t){function e(t){if(t&&!/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(t)&&!/%[^0-9a-f]/i.test(t)&&!/%[0-9a-f](:?[^0-9a-f]|$)/i.test(t)){var e=[],a="",s="",r="",n="",o="",l="";if(e=i(t),a=e[1],s=e[2],r=e[3],n=e[4],o=e[5],a&&a.length&&r.length>=0){if(s&&s.length){if(0!==r.length&&!/^\//.test(r))return}else if(/^\/\//.test(r))return;if(/^[a-z][a-z0-9\+\-\.]*$/.test(a.toLowerCase()))return l+=a+":",s&&s.length&&(l+="//"+s),l+=r,n&&n.length&&(l+="?"+n),o&&o.length&&(l+="#"+o),l}}}function a(t,a){if(e(t)){var s=[],r="",n="",o="",l="",u="",d="",h="";if(s=i(t),r=s[1],n=s[2],o=s[3],u=s[4],d=s[5],r){if(a){if("https"!=r.toLowerCase())return}else if("http"!=r.toLowerCase())return;if(n)return/:(\d+)$/.test(n)&&(l=n.match(/:(\d+)$/)[0],n=n.replace(/:\d+$/,"")),h+=r+":",h+="//"+n,l&&(h+=l),h+=o,u&&u.length&&(h+="?"+u),d&&d.length&&(h+="#"+d),h}}}function s(t){return a(t,!0)}function r(t){return a(t)||s(t)}t.exports.is_uri=e,t.exports.is_http_uri=a,t.exports.is_https_uri=s,t.exports.is_web_uri=r,t.exports.isUri=e,t.exports.isHttpUri=a,t.exports.isHttpsUri=s,t.exports.isWebUri=r;var i=function(t){return t.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/)}}(t)}),e=function(){this.errorMessagesBag={}};return e.prototype.validateAll=function(t){var e=this;return t=t||this.values,new Promise(function(a,s){e.refresh(t),0===Object.keys(e.errorMessagesBag).length?a({success:!0,data:t}):s({success:!1,data:t,errors:e.errorMessagesBag})})},e.prototype.validate=function(t,e,a,s){return this.init(t,e,a,s),this.refresh(t)},e.prototype.init=function(t,e,a,s){this.values=t||{},this.rules=e||{},this.alias=a||{},this.messages=s||[]},e.prototype.refresh=function(t){var a=this;t=t||this.values;for(var s in t)if(a.values.hasOwnProperty(s)){var r=t[s],i=e.getRules(s,a.rules);if(!i)return;a.validateSingleValue(s,r,i.split("|"),a.alias[s])}return this.passes()},e.prototype.passes=function(){return 0===Object.keys(this.errorMessagesBag).length},e.prototype.isValid=function(){return this.passes()},e.prototype.getMessages=function(){return this.errorMessagesBag},e.prototype.validateSingleValue=function(t,e,a,s,r){var i=this;if(void 0===r&&(r=[]),!a)throw new Error("Rules are not present.");a.forEach(function(a){i.validateSingleRule(t,e,a,s)})},e.prototype.validateSingleRule=function(t,a,s,r){s=e.toClassRule(s);var i=null;e.hasParameters(s)&&(i=e.getParameters(s),s=e.separateRuleFromParameter(s));try{this[s](t,a,i,r)}catch(t){throw new Error(s+" is not a Validator.")}},e.prototype.validateRequired=function(t,a,s,r){void 0===s&&(s=null);var i=(r=e.assertAlias(t,r))+" is required.";Number.isInteger(a)||(a?this.removeValidationMessage(t,i):this.addValidationMessages(t,i))},e.prototype.validateInt=function(t,a,s,r){void 0===s&&(s=null),r=e.assertAlias(t,r),a=parseInt(a,10);var i=r+" should be a number.";Number.isInteger(a)?this.removeValidationMessage(t,i):this.addValidationMessages(t,i)},e.prototype.validateEmail=function(t,a,s,r){void 0===s&&(s=null),r=e.assertAlias(t,r);var i="Please enter a valid email address.";/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@(([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(a)?this.removeValidationMessage(t,i):this.addValidationMessages(t,i)},e.prototype.validateArray=function(t,a,s,r){void 0===s&&(s=null);var i=(r=e.assertAlias(t,r))+" is not a valid array.";a&&a.constructor&&a.constructor===Array?this.removeValidationMessage(t,i):this.addValidationMessages(t,i)},e.prototype.validateString=function(t,a,s,r){void 0===s&&(s=null);var i=(r=e.assertAlias(t,r))+" is not a valid string.";"string"!=typeof a?this.addValidationMessages(t,i):this.removeValidationMessage(t,i)},e.prototype.validateGte=function(t,a,s,r){if(r=e.assertAlias(t,r),a=parseInt(a,10),s=parseInt(s,10),isNaN(s))throw new Error(s+" is not a valid integer.");var i=r+" must be greater than "+s+".";a<s?this.addValidationMessages(t,i):this.removeValidationMessage(t,i)},e.prototype.validateLte=function(t,a,s,r){if(r=e.assertAlias(t,r),a=parseInt(a,10),s=parseInt(s,10),isNaN(s))throw new Error(s+" is not a valid integer.");var i=r+" must be less than "+s+".";a>s?this.addValidationMessages(t,i):this.removeValidationMessage(t,i)},e.prototype.validateMin=function(t,e,a,s){if(void 0!==e)return"string"==typeof e?this.validateStringMin(t,e,a,s):"number"==typeof e?this.validateNumberMin(t,e,a,s):e&&e.constructor&&e.constructor===Array?this.validateArrayMin(t,e,a,s):void 0},e.prototype.validateStringMin=function(t,a,s,r){var i=(r=e.assertAlias(t,r))+" cannot be less than "+s+" characters.";a.length<s?this.addValidationMessages(t,i):this.removeValidationMessage(t,i)},e.prototype.validateNumberMin=function(t,a,s,r){var i=(r=e.assertAlias(t,r))+" value cannot be less than "+s;a<s?this.addValidationMessages(t,i):this.removeValidationMessage(t,i)},e.prototype.validateArrayMin=function(t,a,s,r){var i=(r=e.assertAlias(t,r))+" length cannot be less than "+s;a.length<s?this.addValidationMessages(t,i):this.removeValidationMessage(t,i)},e.prototype.validateMax=function(t,e,a,s){if(void 0!==e)return"string"==typeof e?this.validateStringMax(t,e,a,s):"number"==typeof e?this.validateNumberMax(t,e,a,s):e&&e.constructor&&e.constructor===Array?this.validateArrayMax(t,e,a,s):void 0},e.prototype.validateStringMax=function(t,a,s,r){var i=(r=e.assertAlias(t,r))+" cannot be more than "+s+" characters.";a.length>s?this.addValidationMessages(t,i):this.removeValidationMessage(t,i)},e.prototype.validateNumberMax=function(t,a,s,r){var i=(r=e.assertAlias(t,r))+" value cannot be greater than "+s;a>s?this.addValidationMessages(t,i):this.removeValidationMessage(t,i)},e.prototype.validateArrayMax=function(t,a,s,r){var i=(r=e.assertAlias(t,r))+" length cannot be more than "+s;a.length>s?this.addValidationMessages(t,i):this.removeValidationMessage(t,i)},e.prototype.validateUrl=function(e,a,s,r){void 0===s&&(s=null);var i=(r=r||e)+" is not a valid url.";t.isUri(a)?this.removeValidationMessage(e,i):this.addValidationMessages(e,i)},e.prototype.removeValidationMessage=function(t,e){var a=this.getErrors(t),s=a.indexOf(e);s>-1&&a.splice(s,1),0===a.length?delete this.errorMessagesBag[t]:this.errorMessagesBag[t]=a},e.prototype.addValidationMessages=function(t,e){var a=this.getErrors(t);a.includes(e)||a.push(e),this.errorMessagesBag[t]=a},e.prototype.getErrors=function(t){var e=[];return this.errorMessagesBag[t]&&(e=this.errorMessagesBag[t]),e},e.prototype.first=function(t){var a=this.getErrors(t);return a.length>0?e.ucfirst(a[0]):null},e.prototype.hasErrors=function(t){return this.getErrors(t).length>0},e.ucfirst=function(t){return(t+"").charAt(0).toUpperCase()+(t+"").slice(1)},e.toClassRule=function(t){return"validate"+e.ucfirst(t)},e.hasParameters=function(t){return t.split(":").length>1},e.getParameters=function(t){var e=t.split(":")[1].split(",");if(0===e.length)throw new Error("No parameter specified.");return 1===e.length?e[0]:e},e.separateRuleFromParameter=function(t){return t.split(":")[0]},e.getRules=function(t,e){return e[t]?e[t]:null},e.assertAlias=function(t,e){return e||t},e});