New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

abolish

Package Overview
Dependencies
Maintainers
1
Versions
148
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abolish - npm Package Compare versions

Comparing version 5.1.1 to 5.1.2

2

package.json
{
"name": "abolish",
"version": "5.1.1",
"version": "5.1.2",
"description": "A javascript object validator.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,1 +0,1 @@

"use strict";var AbolishStringValidators=(()=>{var a=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var l=a((X,d)=>{"use strict";d.exports={name:"alphaNumeric",error:":param is not AlphaNumeric.",validator:r=>new RegExp(/^[a-z0-9]+$/i).test(r)}});var p=a((Y,f)=>{"use strict";f.exports={name:"boolean",error:":param is not a valid boolean",validator:(r,e,{modifier:t})=>{if(typeof r=="boolean")return!0;if(typeof r=="string"){if(r=r.toLowerCase(),r==="true")return t.setThis(!0),!0;if(r==="false")return t.setThis(!1),!0}else if(typeof r=="number"){if(r===1)return t.setThis(!0),!0;if(r===0)return t.setThis(!1),!0}else return!1}}});var c=a((Z,u)=>{"use strict";u.exports={name:"date",validator:(r,e,{modifier:t})=>{if(r instanceof Date)return!0;if(typeof r=="string"){let s=new Date(r),o=!isNaN(s.getTime());return o&&(typeof e=="string"&&e==="cast"||typeof e=="object"&&(e==null?void 0:e.cast))&&t.setThis(s),o}else return!1},error:":param is not a valid Date!"}});var A=a((rr,m)=>{"use strict";m.exports={name:"email",error:":param is not a valid email.",validator:(r,e,{modifier:t})=>{if(e===!1)return!0;let s=/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(r);return s&&e==="lowercase"&&t&&t.setThis(r.toLowerCase()),s}}});var y=a((er,h)=>{"use strict";h.exports={name:"ipAddress",error:":param is not a valid IP address.",validator:r=>new RegExp(/((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][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d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))/gm).test(r)}});var g=a((tr,b)=>{"use strict";b.exports={name:"json",error:":param is not a valid JSON string",validator:r=>{if(typeof r!="string")return!1;try{return JSON.parse(r),!0}catch(e){return!1}}}});var x=a((ar,V)=>{"use strict";V.exports={name:"jsonDecode",error:":param is not a valid JSON string",validator:(r,e,{modifier:t})=>{t.setThis(JSON.parse(r))}}});var v=a((ir,T)=>{"use strict";T.exports={name:"jsonEncode",error:":param is not a valid JSON string",validator:(r,e,{modifier:t})=>{t.setThis(JSON.stringify(r))}}});var _=a((sr,F)=>{"use strict";F.exports={name:"md5",error:":param is not a valid MD5 string",validator:r=>/^[a-f0-9]{32}$/gi.test(r)}});var N=a((or,w)=>{"use strict";w.exports={name:"number",error:":param is not a valid number",validator:(r,e,{modifier:t})=>{let s=!isNaN(r);return t&&s&&typeof r!="number"&&t.setThis(Number(r)),s}}});var q=a((nr,j)=>{"use strict";j.exports={name:"regex",error:":param failed Regex validation.",validator:(r,e)=>{let t=e instanceof RegExp;return typeof r!="string"?!1:t?e.test(r):new RegExp(e).test(r)}}});var O=a((dr,D)=>{"use strict";function E(r,e){let t=e.getThis();if(typeof t[r]=="function")e.setThis(String(t)[r]());else throw new Error(`Validator string:${r} is not supported!`)}D.exports={name:"string",validator:(r,e,{modifier:t,error:s})=>{if(e===!0||e===void 0)return typeof r=="string"&&r.length>0?!0:s(":param is not a string");if(typeof e!="string")throw new Error("string: Validator option must be a string");if(e.indexOf(",")>0)for(let o of e.split(","))E(o,t);else E(e,t);return!0}}});var S=a((lr,R)=>{"use strict";R.exports={name:"url",error:":param is not a valid URL",validator:r=>{try{return new URL(r),!0}catch(e){return!1}}}});var Q=a((n,J)=>{var i=n&&n.__importDefault||function(r){return r&&r.__esModule?r:{default:r}},M=i(l()),$=i(p()),L=i(c()),I=i(A()),C=i(y()),U=i(g()),z=i(x()),P=i(v()),k=i(_()),B=i(N()),G=i(q()),H=i(O()),K=i(S());J.exports={alphaNumeric:M.default,boolean:$.default,date:L.default,email:I.default,ipAddress:C.default,json:U.default,jsonDecode:z.default,jsonEncode:P.default,md5:k.default,number:B.default,regex:G.default,url:K.default,string:H.default}});return Q();})();
"use strict";var AbolishStringValidators=(()=>{var M=(e,r)=>()=>(e&&(r=e(e=0)),r);var s=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var d=s((ee,l)=>{"use strict";l.exports={name:"alphaNumeric",error:":param is not AlphaNumeric.",validator:e=>new RegExp(/^[a-z0-9]+$/i).test(e)}});var u=s((re,f)=>{"use strict";f.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}}});var c=s((te,p)=>{"use strict";p.exports={name:"date",validator:(e,r,{modifier:t})=>{if(e instanceof Date)return!0;if(typeof e=="string"){let a=new Date(e),o=!isNaN(a.getTime());return o&&(typeof r=="string"&&r==="cast"||typeof r=="object"&&(r==null?void 0:r.cast))&&t.setThis(a),o}else return!1},error:":param is not a valid Date!"}});var y=s((ae,m)=>{"use strict";m.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 A=s((se,h)=>{"use strict";h.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 b=s((ie,g)=>{"use strict";g.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 x=s((oe,T)=>{"use strict";T.exports={name:"jsonDecode",error:":param is not a valid JSON string",validator:(e,r,{modifier:t})=>{t.setThis(JSON.parse(e))}}});var w=s((ne,V)=>{"use strict";V.exports={name:"jsonEncode",error:":param is not a valid JSON string",validator:(e,r,{modifier:t})=>{t.setThis(JSON.stringify(e))}}});var F=s((le,v)=>{"use strict";v.exports={name:"md5",error:":param is not a valid MD5 string",validator:e=>/^[a-f0-9]{32}$/gi.test(e)}});var j=s((de,_)=>{"use strict";_.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 q=s((fe,N)=>{"use strict";N.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 R=s((ue,O)=>{"use strict";function E(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!`)}O.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 o of r.split(","))E(o,t);else E(r,t);return!0}}});function D(e,r,t="Options"){if(typeof r=="string"){if(typeof e===r)return!0;if(r==="array"&&Array.isArray(e))return!0}else{let a=r.includes("array");if(!a&&r.includes(typeof e))return!0;if(a&&(r.includes(typeof e)||Array.isArray(e)))return!0}throw new TypeError(`${t} must be typeof [${r}], but [${typeof e}] was given.`)}var $=M(()=>{"use strict"});var S=s((me,H)=>{"use strict";$();H.exports={name:"url",error:":param is not a valid URL",validator:(e,r,{error:t})=>{D(r,["boolean","object"]);let a;try{a=new URL(e)}catch(o){return!1}if(a&&typeof r=="object"){if(r.allowedHostnames&&!r.allowedHostnames.includes(a.hostname))return t(`:param hostname is not among the allowed hostnames: [${r.allowedHostnames.join(",")}]`);if(r.denyHostnames&&r.denyHostnames.includes(a.hostname))return t(":param hostname is not allowed.")}return!0}}});var Y=s((n,J)=>{var i=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},I=i(d()),L=i(u()),U=i(c()),C=i(y()),z=i(A()),P=i(b()),k=i(x()),B=i(w()),G=i(F()),K=i(j()),Q=i(q()),W=i(R()),X=i(S());J.exports={alphaNumeric:I.default,boolean:L.default,date:U.default,email:C.default,ipAddress:z.default,json:P.default,jsonDecode:k.default,jsonEncode:B.default,md5:G.default,number:K.default,regex:Q.default,url:X.default,string:W.default}});return Y();})();
"use strict";
const types_checker_1 = require("../../src/types-checker");
module.exports = {
name: "url",
error: ":param is not a valid URL",
validator: (str) => {
validator: (str, option, { error }) => {
(0, types_checker_1.assertType)(option, ["boolean", "object"]);
let url;
try {
new URL(str);
return true;
url = new URL(str);
}

@@ -13,2 +15,15 @@ catch (e) {

}
if (url && typeof option === "object") {
if (option.allowedHostnames) {
if (!option.allowedHostnames.includes(url.hostname)) {
return error(`:param hostname is not among the allowed hostnames: [${option.allowedHostnames.join(",")}]`);
}
}
if (option.denyHostnames) {
if (option.denyHostnames.includes(url.hostname)) {
return error(":param hostname is not allowed.");
}
}
}
return true;
}

@@ -15,0 +30,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc