@webiny/validation 0.0.0-unstable.e622468070 → 0.0.0-unstable.e6f0dc8ca7
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/package.json +12 -10
- package/validators/numeric.js +3 -5
- package/validators/numeric.js.map +1 -1
- package/validators/url.js +1 -1
- package/validators/url.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/validation",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.e6f0dc8ca7",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
6
9
|
"repository": {
|
|
7
10
|
"type": "git",
|
|
8
11
|
"url": "https://github.com/webiny/webiny-js.git"
|
|
@@ -15,19 +18,18 @@
|
|
|
15
18
|
],
|
|
16
19
|
"license": "MIT",
|
|
17
20
|
"dependencies": {
|
|
18
|
-
"
|
|
19
|
-
"lodash": "4.17.23"
|
|
21
|
+
"lodash": "4.18.1"
|
|
20
22
|
},
|
|
21
23
|
"devDependencies": {
|
|
22
|
-
"@types/lodash": "4.17.
|
|
23
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
24
|
-
"rimraf": "6.1.
|
|
25
|
-
"typescript": "
|
|
26
|
-
"vitest": "
|
|
24
|
+
"@types/lodash": "4.17.24",
|
|
25
|
+
"@webiny/build-tools": "0.0.0-unstable.e6f0dc8ca7",
|
|
26
|
+
"rimraf": "6.1.3",
|
|
27
|
+
"typescript": "6.0.3",
|
|
28
|
+
"vitest": "4.1.5"
|
|
27
29
|
},
|
|
28
30
|
"publishConfig": {
|
|
29
31
|
"access": "public",
|
|
30
32
|
"directory": "dist"
|
|
31
33
|
},
|
|
32
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "e6f0dc8ca741c1fcc3fec9a5b9e86fdd49544641"
|
|
33
35
|
}
|
package/validators/numeric.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import ValidationError from "../validationError.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// @ts-expect-error
|
|
6
|
-
import isNumeric from "isnumeric";
|
|
2
|
+
const isNumeric = value => {
|
|
3
|
+
return !isNaN(parseFloat(String(value))) && isFinite(Number(value));
|
|
4
|
+
};
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* @function number
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ValidationError","isNumeric","value","isNaN"],"sources":["numeric.ts"],"sourcesContent":["import ValidationError from \"~/validationError.js\";\
|
|
1
|
+
{"version":3,"names":["ValidationError","isNumeric","value","isNaN","parseFloat","String","isFinite","Number"],"sources":["numeric.ts"],"sourcesContent":["import ValidationError from \"~/validationError.js\";\nconst isNumeric = (value: unknown): boolean => {\n return !isNaN(parseFloat(String(value))) && isFinite(Number(value));\n};\n\n/**\n * @function number\n * @description This validator checks if the given value is numeric\n * @param {any} value\n * @return {boolean}\n */\nexport default (value: any) => {\n // Eliminate edge cases\n if (typeof value === \"undefined\" || value === 0 || value === \"0\") {\n return;\n }\n\n if (!value && !isNaN(value)) {\n return;\n }\n\n if (isNumeric(value)) {\n return;\n }\n\n throw new ValidationError(\"Value needs to be numeric.\");\n};\n"],"mappings":"AAAA,OAAOA,eAAe;AACtB,MAAMC,SAAS,GAAIC,KAAc,IAAc;EAC3C,OAAO,CAACC,KAAK,CAACC,UAAU,CAACC,MAAM,CAACH,KAAK,CAAC,CAAC,CAAC,IAAII,QAAQ,CAACC,MAAM,CAACL,KAAK,CAAC,CAAC;AACvE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,eAAgBA,KAAU,IAAK;EAC3B;EACA,IAAI,OAAOA,KAAK,KAAK,WAAW,IAAIA,KAAK,KAAK,CAAC,IAAIA,KAAK,KAAK,GAAG,EAAE;IAC9D;EACJ;EAEA,IAAI,CAACA,KAAK,IAAI,CAACC,KAAK,CAACD,KAAK,CAAC,EAAE;IACzB;EACJ;EAEA,IAAID,SAAS,CAACC,KAAK,CAAC,EAAE;IAClB;EACJ;EAEA,MAAM,IAAIF,eAAe,CAAC,4BAA4B,CAAC;AAC3D,CAAC","ignoreList":[]}
|
package/validators/url.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ValidationError from "../validationError.js";
|
|
2
2
|
const regex = {
|
|
3
|
-
base: new RegExp(/^(https?:\/\/)((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3}))(
|
|
3
|
+
base: new RegExp(/^(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),
|
|
4
4
|
ip: new RegExp(/^(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]?)$/),
|
|
5
5
|
relative: new RegExp(/^\/.*$/),
|
|
6
6
|
href: new RegExp(/^(#|mailto:|tel:)\S*$/)
|
package/validators/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ValidationError","regex","base","RegExp","ip","relative","href","value","params","startsWith","replace","test","includes"],"sources":["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}))(
|
|
1
|
+
{"version":3,"names":["ValidationError","regex","base","RegExp","ip","relative","href","value","params","startsWith","replace","test","includes"],"sources":["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"],"mappings":"AAAA,OAAOA,eAAe;AAEtB,MAAMC,KAAK,GAAG;EACVC,IAAI,EAAE,IAAIC,MAAM,CACZ,qJACJ,CAAC;EACDC,EAAE,EAAE,IAAID,MAAM,CACV,+KACJ,CAAC;EACDE,QAAQ,EAAE,IAAIF,MAAM,CAAC,QAAQ,CAAC;EAC9BG,IAAI,EAAE,IAAIH,MAAM,CAAC,uBAAuB;AAC5C,C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