Comparing version 6.6.1 to 6.6.2
{ | ||
"name": "abolish", | ||
"version": "6.6.1", | ||
"version": "6.6.2", | ||
"description": "A javascript object validator.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -10,3 +10,3 @@ "use strict"; | ||
// Check if email is valid | ||
const isValidMail = /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(email); | ||
const isValidMail = /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,6})+$/.test(email); | ||
// Convert to lowercase if action is set to lowercase | ||
@@ -13,0 +13,0 @@ if (isValidMail && action === "lowercase" && modifier) { |
@@ -1,1 +0,1 @@ | ||
"use strict";var AbolishStringValidators=(()=>{var n=(e,r)=>()=>(e&&(r=e(e=0)),r);var o=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var c=o((ae,d)=>{"use strict";d.exports={name:"alphaNumeric",error:":param is not AlphaNumeric.",validator:e=>new RegExp(/^[a-z0-9]+$/i).test(e)}});var f=o((oe,u)=>{"use strict";u.exports={name:"boolean",error:":param is not a valid boolean",validator:(e,r,{modifier:t})=>{if(typeof e=="boolean")return!0;if(typeof e=="string"){if(e=e.toLowerCase(),e==="true")return t.setThis(!0),!0;if(e==="false")return t.setThis(!1),!0}else if(typeof e=="number"){if(e===1)return t.setThis(!0),!0;if(e===0)return t.setThis(!1),!0}else return!1}}});function p(e,r){return typeof r=="object"&&r instanceof e}var m=n(()=>{"use strict"});var h=o((le,b)=>{"use strict";m();b.exports={name:"date",validator:(e,r,{modifier:t})=>{if(p(Date,e))return!0;if(typeof e=="string"){let a=new Date(e),s=!isNaN(a.getTime());return s&&(typeof r=="string"&&r==="cast"||typeof r=="object"&&(r!=null&&r.cast))&&t.setThis(a),s}else return!1},error:":param is not a valid Date!"}});var y=o((ne,A)=>{"use strict";A.exports={name:"email",error:":param is not a valid email.",validator:(e,r,{modifier:t})=>{if(r===!1)return!0;let a=/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(e);return a&&r==="lowercase"&&t&&t.setThis(e.toLowerCase()),a}}});var v=o((de,g)=>{"use strict";g.exports={name:"ipAddress",error:":param is not a valid IP address.",validator:e=>new RegExp(/((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))/gm).test(e)}});var x=o((ce,V)=>{"use strict";V.exports={name:"json",error:":param is not a valid JSON string",validator:e=>{if(typeof e!="string")return!1;try{return JSON.parse(e),!0}catch(r){return!1}}}});var O=o((ue,w)=>{"use strict";w.exports={name:"jsonDecode",error:":param is not a valid JSON string",validator:(e,r,{modifier:t})=>{t.setThis(JSON.parse(e))}}});var T=o((fe,_)=>{"use strict";_.exports={name:"jsonEncode",error:":param is not a valid JSON string",validator:(e,r,{modifier:t})=>{t.setThis(JSON.stringify(e))}}});var N=o((pe,F)=>{"use strict";F.exports={name:"md5",error:":param is not a valid MD5 string",validator:e=>/^[a-f0-9]{32}$/gi.test(e)}});var j=o((me,R)=>{"use strict";R.exports={name:"number",error:":param is not a valid number",validator:(e,r,{modifier:t})=>{let a=!isNaN(e);return t&&a&&typeof e!="number"&&t.setThis(Number(e)),a}}});var k=o((be,E)=>{"use strict";E.exports={name:"regex",error:":param failed Regex validation.",validator:(e,r)=>{let t=r instanceof RegExp;return typeof e!="string"?!1:t?r.test(e):new RegExp(r).test(e)}}});var C=o((he,D)=>{"use strict";function q(e,r){let t=r.getThis();if(typeof t[e]=="function")r.setThis(String(t)[e]());else throw new Error(`Validator string:${e} is not supported!`)}D.exports={name:"string",validator:(e,r,{modifier:t,error:a})=>{if(r===!0||r===void 0)return typeof e=="string"&&e.length>0?!0:a(":param is not a string");if(typeof r!="string")throw new Error("string: Validator option must be a string");if(r.indexOf(",")>0)for(let s of r.split(","))q(s,t);else q(r,t);return!0}}});function S(e,r,t="Options"){if(!L(e,r))throw new TypeError(`${t} must be typeof [${r}], but [${typeof e}] was given.`);return!0}function L(e,r){if(typeof r=="string")return r==="array"&&Array.isArray(e)?!0:typeof e===r;{let t=r.includes("array");return!t&&r.includes(typeof e)?!0:t&&(r.includes(typeof e)||Array.isArray(e))}}var $=n(()=>{"use strict"});var I=o((ge,U)=>{"use strict";$();U.exports={name:"url",error:":param is not a valid URL",description:["Check that a value is a valid URL","Allow/Block hostnames"],validator:(e,r,{error:t})=>{S(r,["boolean","object"]);let a;try{a=new URL(e)}catch(s){return!1}if(a&&typeof r=="object"){if(r.hostname){if(r.hostname.allow&&!r.hostname.allow.includes(a.hostname))return t(`:param hostname is not among the allowed hostnames: [${r.hostname.allow.join(",")}]`).setCode("hostname.notAllowed");if(r.hostname.block&&r.hostname.block.includes(a.hostname))return t(":param hostname is not allowed.").setCode("hostname.blocked")}if(r.protocol){if(r.protocol.allow&&!r.protocol.allow.includes(a.protocol))return t(`:param protocol is not among the allowed protocols: [${r.protocol.allow.join(",")}]`).setCode("protocol.notAllowed");if(r.protocol.block&&r.protocol.block.includes(a.protocol))return t(":param protocol is not allowed.").setCode("protocol.blocked")}}return!0}}});var re=o((l,J)=>{var i=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},M=i(c()),B=i(f()),K=i(h()),P=i(y()),z=i(v()),G=i(x()),H=i(O()),Q=i(T()),W=i(N()),X=i(j()),Y=i(k()),Z=i(C()),ee=i(I());J.exports={alphaNumeric:M.default,boolean:B.default,date:K.default,email:P.default,ipAddress:z.default,json:G.default,jsonDecode:H.default,jsonEncode:Q.default,md5:W.default,number:X.default,regex:Y.default,url:ee.default,string:Z.default}});return re();})(); | ||
"use strict";var AbolishStringValidators=(()=>{var n=(e,r)=>()=>(e&&(r=e(e=0)),r);var o=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var c=o((ae,d)=>{"use strict";d.exports={name:"alphaNumeric",error:":param is not AlphaNumeric.",validator:e=>new RegExp(/^[a-z0-9]+$/i).test(e)}});var f=o((oe,u)=>{"use strict";u.exports={name:"boolean",error:":param is not a valid boolean",validator:(e,r,{modifier:t})=>{if(typeof e=="boolean")return!0;if(typeof e=="string"){if(e=e.toLowerCase(),e==="true")return t.setThis(!0),!0;if(e==="false")return t.setThis(!1),!0}else if(typeof e=="number"){if(e===1)return t.setThis(!0),!0;if(e===0)return t.setThis(!1),!0}else return!1}}});function p(e,r){return typeof r=="object"&&r instanceof e}var m=n(()=>{"use strict"});var h=o((le,b)=>{"use strict";m();b.exports={name:"date",validator:(e,r,{modifier:t})=>{if(p(Date,e))return!0;if(typeof e=="string"){let a=new Date(e),s=!isNaN(a.getTime());return s&&(typeof r=="string"&&r==="cast"||typeof r=="object"&&(r!=null&&r.cast))&&t.setThis(a),s}else return!1},error:":param is not a valid Date!"}});var y=o((ne,A)=>{"use strict";A.exports={name:"email",error:":param is not a valid email.",validator:(e,r,{modifier:t})=>{if(r===!1)return!0;let a=/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,6})+$/.test(e);return a&&r==="lowercase"&&t&&t.setThis(e.toLowerCase()),a}}});var v=o((de,g)=>{"use strict";g.exports={name:"ipAddress",error:":param is not a valid IP address.",validator:e=>new RegExp(/((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))/gm).test(e)}});var x=o((ce,V)=>{"use strict";V.exports={name:"json",error:":param is not a valid JSON string",validator:e=>{if(typeof e!="string")return!1;try{return JSON.parse(e),!0}catch(r){return!1}}}});var O=o((ue,w)=>{"use strict";w.exports={name:"jsonDecode",error:":param is not a valid JSON string",validator:(e,r,{modifier:t})=>{t.setThis(JSON.parse(e))}}});var T=o((fe,_)=>{"use strict";_.exports={name:"jsonEncode",error:":param is not a valid JSON string",validator:(e,r,{modifier:t})=>{t.setThis(JSON.stringify(e))}}});var N=o((pe,F)=>{"use strict";F.exports={name:"md5",error:":param is not a valid MD5 string",validator:e=>/^[a-f0-9]{32}$/gi.test(e)}});var j=o((me,R)=>{"use strict";R.exports={name:"number",error:":param is not a valid number",validator:(e,r,{modifier:t})=>{let a=!isNaN(e);return t&&a&&typeof e!="number"&&t.setThis(Number(e)),a}}});var k=o((be,E)=>{"use strict";E.exports={name:"regex",error:":param failed Regex validation.",validator:(e,r)=>{let t=r instanceof RegExp;return typeof e!="string"?!1:t?r.test(e):new RegExp(r).test(e)}}});var C=o((he,D)=>{"use strict";function q(e,r){let t=r.getThis();if(typeof t[e]=="function")r.setThis(String(t)[e]());else throw new Error(`Validator string:${e} is not supported!`)}D.exports={name:"string",validator:(e,r,{modifier:t,error:a})=>{if(r===!0||r===void 0)return typeof e=="string"&&e.length>0?!0:a(":param is not a string");if(typeof r!="string")throw new Error("string: Validator option must be a string");if(r.indexOf(",")>0)for(let s of r.split(","))q(s,t);else q(r,t);return!0}}});function S(e,r,t="Options"){if(!L(e,r))throw new TypeError(`${t} must be typeof [${r}], but [${typeof e}] was given.`);return!0}function L(e,r){if(typeof r=="string")return r==="array"&&Array.isArray(e)?!0:typeof e===r;{let t=r.includes("array");return!t&&r.includes(typeof e)?!0:t&&(r.includes(typeof e)||Array.isArray(e))}}var $=n(()=>{"use strict"});var I=o((ge,U)=>{"use strict";$();U.exports={name:"url",error:":param is not a valid URL",description:["Check that a value is a valid URL","Allow/Block hostnames"],validator:(e,r,{error:t})=>{S(r,["boolean","object"]);let a;try{a=new URL(e)}catch(s){return!1}if(a&&typeof r=="object"){if(r.hostname){if(r.hostname.allow&&!r.hostname.allow.includes(a.hostname))return t(`:param hostname is not among the allowed hostnames: [${r.hostname.allow.join(",")}]`).setCode("hostname.notAllowed");if(r.hostname.block&&r.hostname.block.includes(a.hostname))return t(":param hostname is not allowed.").setCode("hostname.blocked")}if(r.protocol){if(r.protocol.allow&&!r.protocol.allow.includes(a.protocol))return t(`:param protocol is not among the allowed protocols: [${r.protocol.allow.join(",")}]`).setCode("protocol.notAllowed");if(r.protocol.block&&r.protocol.block.includes(a.protocol))return t(":param protocol is not allowed.").setCode("protocol.blocked")}}return!0}}});var re=o((l,J)=>{var i=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},M=i(c()),B=i(f()),K=i(h()),P=i(y()),z=i(v()),G=i(x()),H=i(O()),Q=i(T()),W=i(N()),X=i(j()),Y=i(k()),Z=i(C()),ee=i(I());J.exports={alphaNumeric:M.default,boolean:B.default,date:K.default,email:P.default,ipAddress:z.default,json:G.default,jsonDecode:H.default,jsonEncode:Q.default,md5:W.default,number:X.default,regex:Y.default,url:ee.default,string:Z.default}});return re();})(); |