@webiny/validation 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -405
- package/index.d.ts +4 -4
- package/index.js +52 -96
- package/index.js.map +1 -1
- package/package.json +17 -25
- package/types.d.ts +6 -3
- package/types.js +0 -5
- package/validation.d.ts +2 -2
- package/validation.js +66 -184
- package/validation.js.map +1 -1
- package/validationError.js +9 -26
- package/validationError.js.map +1 -1
- package/validators/creditCard.js +24 -66
- package/validators/creditCard.js.map +1 -1
- package/validators/dateGte.js +11 -35
- package/validators/dateGte.js.map +1 -1
- package/validators/dateLte.js +11 -35
- package/validators/dateLte.js.map +1 -1
- package/validators/email.js +9 -39
- package/validators/email.js.map +1 -1
- package/validators/eq.js +8 -39
- package/validators/eq.js.map +1 -1
- package/validators/gt.js +8 -36
- package/validators/gt.js.map +1 -1
- package/validators/gte.js +8 -36
- package/validators/gte.js.map +1 -1
- package/validators/in.js +8 -25
- package/validators/in.js.map +1 -1
- package/validators/integer.js +8 -24
- package/validators/integer.js.map +1 -1
- package/validators/json.js +10 -22
- package/validators/json.js.map +1 -1
- package/validators/lt.js +8 -24
- package/validators/lt.js.map +1 -1
- package/validators/lte.js +8 -24
- package/validators/lte.js.map +1 -1
- package/validators/maxLength.js +15 -42
- package/validators/maxLength.js.map +1 -1
- package/validators/minLength.js +15 -42
- package/validators/minLength.js.map +1 -1
- package/validators/number.js +9 -32
- package/validators/number.js.map +1 -1
- package/validators/numeric.js +9 -40
- package/validators/numeric.js.map +1 -1
- package/validators/password.js +9 -24
- package/validators/password.js.map +1 -1
- package/validators/phone.js +8 -24
- package/validators/phone.js.map +1 -1
- package/validators/required.js +7 -19
- package/validators/required.js.map +1 -1
- package/validators/slug.js +8 -24
- package/validators/slug.js.map +1 -1
- package/validators/time/index.js +29 -75
- package/validators/time/index.js.map +1 -1
- package/validators/timeGte.js +11 -36
- package/validators/timeGte.js.map +1 -1
- package/validators/timeLte.js +11 -36
- package/validators/timeLte.js.map +1 -1
- package/validators/url.js +19 -52
- package/validators/url.js.map +1 -1
- package/types.js.map +0 -1
package/validators/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"validators/url.js","sources":["../../src/validators/url.ts"],"sourcesContent":["import ValidationError from \"~/validationError.js\";\n\nconst regex = {\n base: new RegExp(\n /^(https?:\\/\\/)((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=!-]*)?(#[-a-z\\d_]*)?$/i\n ),\n ip: new RegExp(\n /^(https?:\\/\\/)(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/\n ),\n relative: new RegExp(/^\\/.*$/),\n href: new RegExp(/^(#|mailto:|tel:)\\S*$/)\n};\n\nexport default (value: any, params?: string[]) => {\n if (!value || !params) {\n return;\n }\n value = value + \"\";\n\n if (value.startsWith(\"http://localhost\") || value.startsWith(\"https://localhost\")) {\n value = value.replace(\"//localhost\", \"//localhost.com\");\n }\n\n if (regex.base.test(value)) {\n if (!params.includes(\"noIp\")) {\n return;\n }\n\n if (!regex.ip.test(value)) {\n return;\n }\n }\n\n if (params.includes(\"allowRelative\")) {\n if (regex.relative.test(value)) {\n return;\n }\n }\n\n if (params.includes(\"allowHref\")) {\n if (regex.href.test(value)) {\n return;\n }\n }\n\n throw new ValidationError(\"Value must be a valid URL.\");\n};\n"],"names":["regex","RegExp","value","params","ValidationError"],"mappings":";AAEA,MAAMA,QAAQ;IACV,MAAM,IAAIC,OACN;IAEJ,IAAI,IAAIA,OACJ;IAEJ,UAAU,IAAIA,OAAO;IACrB,MAAM,IAAIA,OAAO;AACrB;AAEA,YAAgB,CAAAC,OAAYC;IACxB,IAAI,CAACD,SAAS,CAACC,QACX;IAEJD,SAAgB;IAEhB,IAAIA,MAAM,UAAU,CAAC,uBAAuBA,MAAM,UAAU,CAAC,sBACzDA,QAAQA,MAAM,OAAO,CAAC,eAAe;IAGzC,IAAIF,MAAM,IAAI,CAAC,IAAI,CAACE,QAAQ;QACxB,IAAI,CAACC,OAAO,QAAQ,CAAC,SACjB;QAGJ,IAAI,CAACH,MAAM,EAAE,CAAC,IAAI,CAACE,QACf;IAER;IAEA,IAAIC,OAAO,QAAQ,CAAC,kBAChB;QAAA,IAAIH,MAAM,QAAQ,CAAC,IAAI,CAACE,QACpB;IACJ;IAGJ,IAAIC,OAAO,QAAQ,CAAC,cAChB;QAAA,IAAIH,MAAM,IAAI,CAAC,IAAI,CAACE,QAChB;IACJ;IAGJ,MAAM,IAAIE,gBAAgB;AAC9B"}
|
package/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import ValidationError from \"~/validationError\";\n\ntype ValidatorResult = boolean | ValidationError | void | Promise<boolean | ValidationError | void>;\n/**\n * @typedef Validator\n * @name Validator\n * @description This type defines the validator function.\n * @param {any} value This is the value being validated.\n * @param {Array<string>} parameters (Optional) This represents an array validator parameters.\n * @throws {ValidationError}\n */\nexport type Validator = (value: any, params?: string[]) => ValidatorResult;\n\n/**\n * @typedef ValidateOptions\n * @name ValidateOptions\n * @description This is an object containing validation options.\n * @property {boolean} throw Should validation throw on failure? Default: true.\n */\nexport interface ValidateOptions {\n throw?: boolean;\n}\n\n/**\n * @private\n * @typedef ParsedValidators\n * @name ParsedValidators\n * @description An object containing validators with parameters: `{ [string]: Array<string> }`.\n */\nexport interface ParsedValidators {\n [key: string]: Array<string>;\n}\n"],"mappings":""}
|