@validex/core 1.0.0

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.
Files changed (101) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +583 -0
  3. package/dist/checks/index.cjs +51 -0
  4. package/dist/checks/index.d.cts +207 -0
  5. package/dist/checks/index.d.ts +207 -0
  6. package/dist/checks/index.js +51 -0
  7. package/dist/chunk-2OTGUKO7.cjs +26 -0
  8. package/dist/chunk-4HUGF4EZ.js +0 -0
  9. package/dist/chunk-5CYBSNNG.cjs +33 -0
  10. package/dist/chunk-5DOFRLSB.js +30 -0
  11. package/dist/chunk-64X6D23X.cjs +24 -0
  12. package/dist/chunk-6MGS4JWP.js +152 -0
  13. package/dist/chunk-AGJWIOFF.js +24 -0
  14. package/dist/chunk-BAFEYOPS.js +43 -0
  15. package/dist/chunk-BYMZTDYD.js +56 -0
  16. package/dist/chunk-D232V332.cjs +30 -0
  17. package/dist/chunk-FD77PZXB.js +9 -0
  18. package/dist/chunk-H3XHQLZF.cjs +43 -0
  19. package/dist/chunk-ISY3F7TI.cjs +239 -0
  20. package/dist/chunk-JEKRBIPN.cjs +1 -0
  21. package/dist/chunk-KTN4NQQL.js +33 -0
  22. package/dist/chunk-LSQNDPFQ.cjs +9 -0
  23. package/dist/chunk-NDLUDRZJ.js +24 -0
  24. package/dist/chunk-OCTLUBGT.cjs +24 -0
  25. package/dist/chunk-OFT3FQPJ.cjs +152 -0
  26. package/dist/chunk-OOFMB7K5.js +34 -0
  27. package/dist/chunk-OTPQTLPM.js +50 -0
  28. package/dist/chunk-P3FRVJ3U.cjs +50 -0
  29. package/dist/chunk-PFPNNQGJ.js +30 -0
  30. package/dist/chunk-PQ4TUE2Q.cjs +2688 -0
  31. package/dist/chunk-SMDC2EAD.js +26 -0
  32. package/dist/chunk-TB6J73U7.js +239 -0
  33. package/dist/chunk-TBVAKZA5.js +2688 -0
  34. package/dist/chunk-TSPTIW3V.cjs +34 -0
  35. package/dist/chunk-WE2OD5XD.cjs +30 -0
  36. package/dist/chunk-WKVMDEA3.js +26 -0
  37. package/dist/chunk-ZAUX2RGL.cjs +56 -0
  38. package/dist/chunk-ZWIO2MJX.cjs +26 -0
  39. package/dist/cli/index.cjs +120 -0
  40. package/dist/cli/index.d.cts +1 -0
  41. package/dist/cli/index.d.ts +1 -0
  42. package/dist/cli/index.js +120 -0
  43. package/dist/commonPasswords-3BYUBARZ.cjs +10 -0
  44. package/dist/commonPasswords-ZYOEI6PG.js +10 -0
  45. package/dist/countryCodes-EKJKVHR5.cjs +10 -0
  46. package/dist/countryCodes-RTJZVCLB.js +10 -0
  47. package/dist/countryCodes-VY56VZPT.cjs +255 -0
  48. package/dist/countryCodes-YRY75MQP.js +255 -0
  49. package/dist/creditCardPrefixes-EXMJZGE7.cjs +10 -0
  50. package/dist/creditCardPrefixes-EZK7T4IZ.js +10 -0
  51. package/dist/creditCardPrefixes-HKWKCHNU.cjs +48 -0
  52. package/dist/creditCardPrefixes-QP3S4ZAU.js +48 -0
  53. package/dist/currencyCodes-GU6W3HSN.cjs +171 -0
  54. package/dist/currencyCodes-P67AASLW.js +171 -0
  55. package/dist/currencyCodes-RMRLGDME.cjs +10 -0
  56. package/dist/currencyCodes-U6TSAWDR.js +10 -0
  57. package/dist/disposableDomains-DCXSV422.js +10 -0
  58. package/dist/disposableDomains-USU2JQSF.cjs +10 -0
  59. package/dist/ibanPatterns-2PM32RIY.cjs +85 -0
  60. package/dist/ibanPatterns-BSQUWKLY.js +85 -0
  61. package/dist/ibanPatterns-KTLY6TZY.cjs +10 -0
  62. package/dist/ibanPatterns-LJRPR7FV.js +10 -0
  63. package/dist/index-Cid7Ygr_.d.cts +950 -0
  64. package/dist/index-Cid7Ygr_.d.ts +950 -0
  65. package/dist/index.cjs +361 -0
  66. package/dist/index.d.cts +132 -0
  67. package/dist/index.d.ts +132 -0
  68. package/dist/index.js +361 -0
  69. package/dist/locales/en.cjs +10 -0
  70. package/dist/locales/en.d.cts +234 -0
  71. package/dist/locales/en.d.ts +234 -0
  72. package/dist/locales/en.js +10 -0
  73. package/dist/passwordsTier1-NAZLSHKW.cjs +105 -0
  74. package/dist/passwordsTier1-OYRMLOWD.js +105 -0
  75. package/dist/passwordsTier2-GYJTYGY6.cjs +906 -0
  76. package/dist/passwordsTier2-JAEO5AYY.js +906 -0
  77. package/dist/passwordsTier3-BAPUFHZM.cjs +9006 -0
  78. package/dist/passwordsTier3-E6WBK5OB.js +9006 -0
  79. package/dist/phoneDetection-AFSSD4IB.cjs +6 -0
  80. package/dist/phoneDetection-G23LZ6MU.js +6 -0
  81. package/dist/phoneParser-2RTXDB6H.js +10 -0
  82. package/dist/phoneParser-CGRP2OUN.cjs +10 -0
  83. package/dist/postalCodes-4EZVDT2N.cjs +10 -0
  84. package/dist/postalCodes-ZPAJB3P5.js +10 -0
  85. package/dist/reservedUsernames-3QPPKUXR.cjs +246 -0
  86. package/dist/reservedUsernames-GIK6NX3J.js +246 -0
  87. package/dist/reservedUsernames-QR4ONXSL.js +10 -0
  88. package/dist/reservedUsernames-W65FGT6A.cjs +10 -0
  89. package/dist/rules/index.cjs +66 -0
  90. package/dist/rules/index.d.cts +2 -0
  91. package/dist/rules/index.d.ts +2 -0
  92. package/dist/rules/index.js +66 -0
  93. package/dist/utilities/index.cjs +8 -0
  94. package/dist/utilities/index.d.cts +47 -0
  95. package/dist/utilities/index.d.ts +47 -0
  96. package/dist/utilities/index.js +8 -0
  97. package/dist/vatPatterns-BLRXHNCP.js +36 -0
  98. package/dist/vatPatterns-DNVZJPTW.js +10 -0
  99. package/dist/vatPatterns-NPN6SV2Y.cjs +36 -0
  100. package/dist/vatPatterns-RRHUTA3U.cjs +10 -0
  101. package/package.json +133 -0
@@ -0,0 +1,66 @@
1
+ import {
2
+ BusinessName,
3
+ Color,
4
+ Country,
5
+ CreditCard,
6
+ Currency,
7
+ DateTime,
8
+ Email,
9
+ Iban,
10
+ IpAddress,
11
+ Jwt,
12
+ LicenseKey,
13
+ MacAddress,
14
+ Password,
15
+ PasswordConfirmation,
16
+ PersonName,
17
+ Phone,
18
+ PostalCode,
19
+ Slug,
20
+ Text,
21
+ Token,
22
+ Url,
23
+ Username,
24
+ Uuid,
25
+ VatNumber,
26
+ Website
27
+ } from "../chunk-TBVAKZA5.js";
28
+ import "../chunk-OOFMB7K5.js";
29
+ import "../chunk-NDLUDRZJ.js";
30
+ import "../chunk-PFPNNQGJ.js";
31
+ import "../chunk-SMDC2EAD.js";
32
+ import "../chunk-KTN4NQQL.js";
33
+ import "../chunk-5DOFRLSB.js";
34
+ import "../chunk-OTPQTLPM.js";
35
+ import "../chunk-WKVMDEA3.js";
36
+ import "../chunk-BYMZTDYD.js";
37
+ import "../chunk-6MGS4JWP.js";
38
+ import "../chunk-TB6J73U7.js";
39
+ import "../chunk-AGJWIOFF.js";
40
+ export {
41
+ BusinessName,
42
+ Color,
43
+ Country,
44
+ CreditCard,
45
+ Currency,
46
+ DateTime,
47
+ Email,
48
+ Iban,
49
+ IpAddress,
50
+ Jwt,
51
+ LicenseKey,
52
+ MacAddress,
53
+ Password,
54
+ PasswordConfirmation,
55
+ PersonName,
56
+ Phone,
57
+ PostalCode,
58
+ Slug,
59
+ Text,
60
+ Token,
61
+ Url,
62
+ Username,
63
+ Uuid,
64
+ VatNumber,
65
+ Website
66
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkH3XHQLZFcjs = require('../chunk-H3XHQLZF.cjs');
5
+
6
+
7
+
8
+ exports.requiredWhen = _chunkH3XHQLZFcjs.requiredWhen; exports.sameAs = _chunkH3XHQLZFcjs.sameAs;
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+
3
+ /** Options for the requiredWhen conditional refinement. */
4
+ interface RequiredWhenOptions {
5
+ /** Custom error message when the field is missing. */
6
+ readonly message?: string | undefined;
7
+ /** Label for the field in error messages. */
8
+ readonly label?: string | undefined;
9
+ }
10
+ /**
11
+ * requiredWhen
12
+ * Creates a Zod superRefine callback that marks a field as
13
+ * required when the given condition evaluates to true. The
14
+ * condition receives the full parent object for cross-field
15
+ * logic. An error is attached to the specified field path
16
+ * when the condition is met and the field is empty or absent.
17
+ *
18
+ * @param field - Field name that becomes required.
19
+ * @param condition - Predicate receiving the parent data object.
20
+ * @param options - Optional configuration (custom message).
21
+ * @returns A superRefine callback for use with z.object().
22
+ */
23
+ declare function requiredWhen(field: string, condition: (data: Record<string, unknown>) => boolean, options?: RequiredWhenOptions): (data: Record<string, unknown>, ctx: z.RefinementCtx) => void;
24
+
25
+ /** Options for the sameAs cross-field equality refinement. */
26
+ interface SameAsOptions {
27
+ /** Custom error message when fields do not match. */
28
+ readonly message?: string | undefined;
29
+ /** Label for the source field in error messages. */
30
+ readonly label?: string | undefined;
31
+ /** Label for the target field in error messages. */
32
+ readonly targetLabel?: string | undefined;
33
+ }
34
+ /**
35
+ * sameAs
36
+ * Creates a Zod superRefine callback that verifies two fields
37
+ * on the parent object hold the same value. The validation
38
+ * error is attached to the source field path.
39
+ *
40
+ * @param sourceField - Field that must match the target.
41
+ * @param targetField - Field whose value is the reference.
42
+ * @param options - Optional configuration (custom message).
43
+ * @returns A superRefine callback for use with z.object().
44
+ */
45
+ declare function sameAs(sourceField: string, targetField: string, options?: SameAsOptions): (data: Record<string, unknown>, ctx: z.RefinementCtx) => void;
46
+
47
+ export { requiredWhen, sameAs };
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+
3
+ /** Options for the requiredWhen conditional refinement. */
4
+ interface RequiredWhenOptions {
5
+ /** Custom error message when the field is missing. */
6
+ readonly message?: string | undefined;
7
+ /** Label for the field in error messages. */
8
+ readonly label?: string | undefined;
9
+ }
10
+ /**
11
+ * requiredWhen
12
+ * Creates a Zod superRefine callback that marks a field as
13
+ * required when the given condition evaluates to true. The
14
+ * condition receives the full parent object for cross-field
15
+ * logic. An error is attached to the specified field path
16
+ * when the condition is met and the field is empty or absent.
17
+ *
18
+ * @param field - Field name that becomes required.
19
+ * @param condition - Predicate receiving the parent data object.
20
+ * @param options - Optional configuration (custom message).
21
+ * @returns A superRefine callback for use with z.object().
22
+ */
23
+ declare function requiredWhen(field: string, condition: (data: Record<string, unknown>) => boolean, options?: RequiredWhenOptions): (data: Record<string, unknown>, ctx: z.RefinementCtx) => void;
24
+
25
+ /** Options for the sameAs cross-field equality refinement. */
26
+ interface SameAsOptions {
27
+ /** Custom error message when fields do not match. */
28
+ readonly message?: string | undefined;
29
+ /** Label for the source field in error messages. */
30
+ readonly label?: string | undefined;
31
+ /** Label for the target field in error messages. */
32
+ readonly targetLabel?: string | undefined;
33
+ }
34
+ /**
35
+ * sameAs
36
+ * Creates a Zod superRefine callback that verifies two fields
37
+ * on the parent object hold the same value. The validation
38
+ * error is attached to the source field path.
39
+ *
40
+ * @param sourceField - Field that must match the target.
41
+ * @param targetField - Field whose value is the reference.
42
+ * @param options - Optional configuration (custom message).
43
+ * @returns A superRefine callback for use with z.object().
44
+ */
45
+ declare function sameAs(sourceField: string, targetField: string, options?: SameAsOptions): (data: Record<string, unknown>, ctx: z.RefinementCtx) => void;
46
+
47
+ export { requiredWhen, sameAs };
@@ -0,0 +1,8 @@
1
+ import {
2
+ requiredWhen,
3
+ sameAs
4
+ } from "../chunk-BAFEYOPS.js";
5
+ export {
6
+ requiredWhen,
7
+ sameAs
8
+ };
@@ -0,0 +1,36 @@
1
+ // src/data/vatPatterns.json
2
+ var vatPatterns_default = [
3
+ { country: "AT", regex: "^U\\d{8}$" },
4
+ { country: "BE", regex: "^[01]\\d{9}$" },
5
+ { country: "BG", regex: "^\\d{9,10}$" },
6
+ { country: "HR", regex: "^\\d{11}$" },
7
+ { country: "CY", regex: "^\\d{8}[A-Z]$" },
8
+ { country: "CZ", regex: "^\\d{8,10}$" },
9
+ { country: "DK", regex: "^\\d{8}$" },
10
+ { country: "EE", regex: "^\\d{9}$" },
11
+ { country: "FI", regex: "^\\d{8}$" },
12
+ { country: "FR", regex: "^[0-9A-Z]{2}\\d{9}$" },
13
+ { country: "DE", regex: "^\\d{9}$" },
14
+ { country: "EL", regex: "^\\d{9}$" },
15
+ { country: "HU", regex: "^\\d{8}$" },
16
+ { country: "IE", regex: "^(\\d{7}[A-Z]{1,2}|\\d[A-Z]\\d{5}[A-Z])$" },
17
+ { country: "IT", regex: "^\\d{11}$" },
18
+ { country: "LV", regex: "^\\d{11}$" },
19
+ { country: "LT", regex: "^(\\d{9}|\\d{12})$" },
20
+ { country: "LU", regex: "^\\d{8}$" },
21
+ { country: "MT", regex: "^\\d{8}$" },
22
+ { country: "NL", regex: "^\\d{9}B\\d{2}$" },
23
+ { country: "PL", regex: "^\\d{10}$" },
24
+ { country: "PT", regex: "^\\d{9}$" },
25
+ { country: "RO", regex: "^\\d{2,10}$" },
26
+ { country: "SK", regex: "^\\d{10}$" },
27
+ { country: "SI", regex: "^\\d{8}$" },
28
+ { country: "ES", regex: "^[A-Z0-9]\\d{7}[A-Z0-9]$" },
29
+ { country: "SE", regex: "^\\d{12}$" },
30
+ { country: "GB", regex: "^(\\d{9}|\\d{12}|GD\\d{3}|HA\\d{3})$" },
31
+ { country: "CHE", regex: "^\\d{9}$" },
32
+ { country: "NO", regex: "^\\d{9}MVA$" }
33
+ ];
34
+ export {
35
+ vatPatterns_default as default
36
+ };
@@ -0,0 +1,10 @@
1
+ import {
2
+ clearVatPatternsCache,
3
+ getVatPatterns,
4
+ loadVatPatterns
5
+ } from "./chunk-5DOFRLSB.js";
6
+ export {
7
+ clearVatPatternsCache,
8
+ getVatPatterns,
9
+ loadVatPatterns
10
+ };
@@ -0,0 +1,36 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/data/vatPatterns.json
2
+ var vatPatterns_default = [
3
+ { country: "AT", regex: "^U\\d{8}$" },
4
+ { country: "BE", regex: "^[01]\\d{9}$" },
5
+ { country: "BG", regex: "^\\d{9,10}$" },
6
+ { country: "HR", regex: "^\\d{11}$" },
7
+ { country: "CY", regex: "^\\d{8}[A-Z]$" },
8
+ { country: "CZ", regex: "^\\d{8,10}$" },
9
+ { country: "DK", regex: "^\\d{8}$" },
10
+ { country: "EE", regex: "^\\d{9}$" },
11
+ { country: "FI", regex: "^\\d{8}$" },
12
+ { country: "FR", regex: "^[0-9A-Z]{2}\\d{9}$" },
13
+ { country: "DE", regex: "^\\d{9}$" },
14
+ { country: "EL", regex: "^\\d{9}$" },
15
+ { country: "HU", regex: "^\\d{8}$" },
16
+ { country: "IE", regex: "^(\\d{7}[A-Z]{1,2}|\\d[A-Z]\\d{5}[A-Z])$" },
17
+ { country: "IT", regex: "^\\d{11}$" },
18
+ { country: "LV", regex: "^\\d{11}$" },
19
+ { country: "LT", regex: "^(\\d{9}|\\d{12})$" },
20
+ { country: "LU", regex: "^\\d{8}$" },
21
+ { country: "MT", regex: "^\\d{8}$" },
22
+ { country: "NL", regex: "^\\d{9}B\\d{2}$" },
23
+ { country: "PL", regex: "^\\d{10}$" },
24
+ { country: "PT", regex: "^\\d{9}$" },
25
+ { country: "RO", regex: "^\\d{2,10}$" },
26
+ { country: "SK", regex: "^\\d{10}$" },
27
+ { country: "SI", regex: "^\\d{8}$" },
28
+ { country: "ES", regex: "^[A-Z0-9]\\d{7}[A-Z0-9]$" },
29
+ { country: "SE", regex: "^\\d{12}$" },
30
+ { country: "GB", regex: "^(\\d{9}|\\d{12}|GD\\d{3}|HA\\d{3})$" },
31
+ { country: "CHE", regex: "^\\d{9}$" },
32
+ { country: "NO", regex: "^\\d{9}MVA$" }
33
+ ];
34
+
35
+
36
+ exports.default = vatPatterns_default;
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkD232V332cjs = require('./chunk-D232V332.cjs');
6
+
7
+
8
+
9
+
10
+ exports.clearVatPatternsCache = _chunkD232V332cjs.clearVatPatternsCache; exports.getVatPatterns = _chunkD232V332cjs.getVatPatterns; exports.loadVatPatterns = _chunkD232V332cjs.loadVatPatterns;
package/package.json ADDED
@@ -0,0 +1,133 @@
1
+ {
2
+ "name": "@validex/core",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "description": "Type-safe validation rules built on Zod",
6
+ "author": "Ciprian Toma",
7
+ "license": "MIT",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "homepage": "https://github.com/chiptoma/validex#readme",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/chiptoma/validex.git",
15
+ "directory": "packages/core"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/chiptoma/validex/issues"
19
+ },
20
+ "keywords": [
21
+ "zod",
22
+ "validation",
23
+ "zod4",
24
+ "email",
25
+ "phone",
26
+ "typescript",
27
+ "i18n",
28
+ "tree-shakeable"
29
+ ],
30
+ "sideEffects": false,
31
+ "exports": {
32
+ ".": {
33
+ "import": {
34
+ "types": "./dist/index.d.ts",
35
+ "default": "./dist/index.js"
36
+ },
37
+ "require": {
38
+ "types": "./dist/index.d.cts",
39
+ "default": "./dist/index.cjs"
40
+ }
41
+ },
42
+ "./rules": {
43
+ "import": {
44
+ "types": "./dist/rules/index.d.ts",
45
+ "default": "./dist/rules/index.js"
46
+ },
47
+ "require": {
48
+ "types": "./dist/rules/index.d.cts",
49
+ "default": "./dist/rules/index.cjs"
50
+ }
51
+ },
52
+ "./checks": {
53
+ "import": {
54
+ "types": "./dist/checks/index.d.ts",
55
+ "default": "./dist/checks/index.js"
56
+ },
57
+ "require": {
58
+ "types": "./dist/checks/index.d.cts",
59
+ "default": "./dist/checks/index.cjs"
60
+ }
61
+ },
62
+ "./utilities": {
63
+ "import": {
64
+ "types": "./dist/utilities/index.d.ts",
65
+ "default": "./dist/utilities/index.js"
66
+ },
67
+ "require": {
68
+ "types": "./dist/utilities/index.d.cts",
69
+ "default": "./dist/utilities/index.cjs"
70
+ }
71
+ },
72
+ "./locales/en": {
73
+ "import": {
74
+ "types": "./dist/locales/en.d.ts",
75
+ "default": "./dist/locales/en.js"
76
+ },
77
+ "require": {
78
+ "types": "./dist/locales/en.d.cts",
79
+ "default": "./dist/locales/en.cjs"
80
+ }
81
+ }
82
+ },
83
+ "main": "./dist/index.cjs",
84
+ "module": "./dist/index.js",
85
+ "types": "./dist/index.d.ts",
86
+ "bin": {
87
+ "validex": "./dist/cli/index.js"
88
+ },
89
+ "files": [
90
+ "CHANGELOG.md",
91
+ "LICENSE",
92
+ "README.md",
93
+ "dist"
94
+ ],
95
+ "engines": {
96
+ "node": ">=22"
97
+ },
98
+ "peerDependencies": {
99
+ "zod": "^3.25.0 || ^4.0.0"
100
+ },
101
+ "dependencies": {
102
+ "disposable-email-domains-js": "^1.24.0",
103
+ "libphonenumber-js": "^1.12.41",
104
+ "postcode-validator": "^3.10.15"
105
+ },
106
+ "devDependencies": {
107
+ "@faker-js/faker": "^10.4.0",
108
+ "esbuild": "^0.28.0",
109
+ "fast-check": "^4.6.0",
110
+ "tsx": "^4.21.0"
111
+ },
112
+ "scripts": {
113
+ "build": "tsup",
114
+ "typecheck": "tsc --noEmit",
115
+ "test": "vitest run",
116
+ "test:watch": "vitest",
117
+ "test:coverage": "vitest run --coverage",
118
+ "test:unit": "vitest run tests/unit",
119
+ "test:unit:rules": "vitest run tests/unit/rules",
120
+ "test:unit:checks": "vitest run tests/unit/checks",
121
+ "test:unit:core": "vitest run tests/unit/core",
122
+ "test:unit:config": "vitest run tests/unit/config",
123
+ "test:unit:internal": "vitest run tests/unit/internal",
124
+ "test:unit:loaders": "vitest run tests/unit/loaders",
125
+ "test:unit:utilities": "vitest run tests/unit/utilities",
126
+ "test:unit:cli": "vitest run tests/unit/cli",
127
+ "test:integration": "vitest run tests/integration",
128
+ "test:e2e": "vitest run tests/e2e",
129
+ "test:property": "vitest run tests/property",
130
+ "test:fuzz": "vitest run tests/fuzz",
131
+ "test:bundle-size": "vitest run tests/unit/build/bundleSize.test.ts"
132
+ }
133
+ }