UNPKG

fortify-schema

Version:

A modern TypeScript validation library designed around familiar interface syntax and powerful conditional validation. Experience schema validation that feels natural to TypeScript developers while unlocking advanced runtime validation capabilities.

103 lines (99 loc) 2.64 kB
'use strict'; var createUrlArgsEnumFArray = require('./createUrlArgsEnumFArray.js'); const UrlArgArray = [ "url.https", "url.http", "url.web", "url.dev", "url.ftp", ]; const UrlArgsEnum = createUrlArgsEnumFArray.createUrlArgsEnumFromArray(UrlArgArray); class UrlArgs { static selectArg(urlArg) { return this.getSpecificArg(urlArg) || this.args["url.web"]; } static getSpecificArg(str) { return this.args[str]; } static isCorrectArg(str) { const rgx = /^url\./; if (!rgx.test(str)) { return { isValid: false, error: "Invalid url arg. Argument must start with 'url.'", }; } const args = this.getSpecificArg(str); if (!args) { return { isValid: false, error: "Invalid url arg. Argument not found", }; } return { isValid: true, argsValue: args, }; } } UrlArgs.args = { "url.https": { match: { protocols: ["https"], allowLocalhost: false, allowPrivateIPs: false, maxLength: 2048, requireTLD: true, allowDataUrls: false, allowIPAddresses: false, }, }, "url.http": { match: { protocols: ["http"], allowLocalhost: false, allowPrivateIPs: false, maxLength: 2048, requireTLD: true, allowDataUrls: false, allowIPAddresses: false, }, }, "url.web": { match: { protocols: ["http", "https"], allowLocalhost: false, allowPrivateIPs: false, maxLength: 2048, requireTLD: true, allowDataUrls: false, allowIPAddresses: false, }, }, "url.dev": { match: { protocols: ["http", "https", "ftp", "ws", "wss", "file"], allowLocalhost: true, allowPrivateIPs: true, maxLength: 2048, requireTLD: false, allowDataUrls: true, allowIPAddresses: true, }, }, "url.ftp": { match: { protocols: ["ftp"], allowLocalhost: false, allowPrivateIPs: false, maxLength: 2048, requireTLD: true, allowDataUrls: false, allowIPAddresses: false, }, }, }; exports.UrlArgArray = UrlArgArray; exports.UrlArgs = UrlArgs; exports.UrlArgsEnum = UrlArgsEnum; //# sourceMappingURL=UrlArgs.js.map