unischema 1.1.0 → 1.2.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.
- package/README.md +151 -2
- package/dist/adapters/backend/index.d.mts +2 -2
- package/dist/adapters/backend/index.d.ts +2 -2
- package/dist/adapters/backend/index.js +11 -11
- package/dist/adapters/backend/index.mjs +8 -8
- package/dist/adapters/frontend/index.d.mts +2 -2
- package/dist/adapters/frontend/index.d.ts +2 -2
- package/dist/adapters/frontend/index.js +10 -10
- package/dist/adapters/frontend/index.mjs +8 -8
- package/dist/{chunk-XGTUU27F.mjs → chunk-5A4ITJVD.mjs} +1 -1
- package/dist/{chunk-ASKTY6EG.js → chunk-66RFUBVU.js} +20 -20
- package/dist/{chunk-KHHJD6QK.mjs → chunk-75YSYC4K.mjs} +1 -1
- package/dist/{chunk-BNIB23NQ.js → chunk-76BBWQDH.js} +13 -13
- package/dist/{chunk-ELL7U7IC.mjs → chunk-7XES4A3M.mjs} +1 -1
- package/dist/{chunk-FRBZHN4K.mjs → chunk-COMVAVFU.mjs} +1 -1
- package/dist/chunk-DT2TQZU7.js +796 -0
- package/dist/{chunk-2JYFKT3R.js → chunk-FPCCH55A.js} +14 -14
- package/dist/{chunk-3FANCMEF.js → chunk-IUXRLMET.js} +34 -34
- package/dist/{chunk-CQYXR2LZ.js → chunk-JEW6U6CB.js} +65 -65
- package/dist/{chunk-XC4DKEXP.mjs → chunk-KZCV5IW4.mjs} +1 -1
- package/dist/{chunk-FKDWSZIV.mjs → chunk-KZZ7NVU3.mjs} +4 -2
- package/dist/{chunk-3TS35CVJ.mjs → chunk-MFEBMQAU.mjs} +341 -40
- package/dist/{chunk-NUW55QTO.js → chunk-OIYG5D2I.js} +4 -2
- package/dist/{chunk-VWP24NYS.mjs → chunk-RW6HDA5H.mjs} +1 -1
- package/dist/{chunk-FZ7K2PC7.js → chunk-TXT36BCE.js} +35 -35
- package/dist/index-C17xs-fU.d.mts +140 -0
- package/dist/index-C17xs-fU.d.ts +140 -0
- package/dist/index.d.mts +26 -8
- package/dist/index.d.ts +26 -8
- package/dist/index.js +262 -25
- package/dist/index.mjs +228 -14
- package/dist/{schema-DYU1zGVm.d.mts → schema-DYE8Wz8X.d.mts} +84 -2
- package/dist/{schema-CpAjXgEF.d.ts → schema-Dtp-joeT.d.ts} +84 -2
- package/dist/validators/array.d.mts +1 -1
- package/dist/validators/array.d.ts +1 -1
- package/dist/validators/array.js +8 -8
- package/dist/validators/array.mjs +2 -2
- package/dist/validators/common.d.mts +1 -1
- package/dist/validators/common.d.ts +1 -1
- package/dist/validators/common.js +7 -7
- package/dist/validators/common.mjs +2 -2
- package/dist/validators/date.d.mts +1 -1
- package/dist/validators/date.d.ts +1 -1
- package/dist/validators/date.js +12 -12
- package/dist/validators/date.mjs +2 -2
- package/dist/validators/index.d.mts +2 -2
- package/dist/validators/index.d.ts +2 -2
- package/dist/validators/index.js +68 -68
- package/dist/validators/index.mjs +7 -7
- package/dist/validators/number.d.mts +1 -1
- package/dist/validators/number.d.ts +1 -1
- package/dist/validators/number.js +13 -13
- package/dist/validators/number.mjs +2 -2
- package/dist/validators/object.d.mts +1 -1
- package/dist/validators/object.d.ts +1 -1
- package/dist/validators/object.js +6 -6
- package/dist/validators/object.mjs +2 -2
- package/dist/validators/string.d.mts +1 -1
- package/dist/validators/string.d.ts +1 -1
- package/dist/validators/string.js +19 -19
- package/dist/validators/string.mjs +2 -2
- package/package.json +47 -5
- package/dist/chunk-BJLVOIAP.js +0 -491
- package/dist/index-BQR7OrY7.d.mts +0 -80
- package/dist/index-BQR7OrY7.d.ts +0 -80
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkOIYG5D2I_js = require('./chunk-OIYG5D2I.js');
|
|
4
4
|
|
|
5
5
|
// src/validators/common/notMatches.ts
|
|
6
6
|
var notMatchesValidator = (value, params, context) => {
|
|
7
|
-
if (
|
|
7
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
8
8
|
const fieldName = params?.field;
|
|
9
9
|
const soft = params?.soft;
|
|
10
10
|
const message = params?.message;
|
|
@@ -12,7 +12,7 @@ var notMatchesValidator = (value, params, context) => {
|
|
|
12
12
|
const root = context.root;
|
|
13
13
|
const otherValue = root?.[fieldName];
|
|
14
14
|
if (value === otherValue) {
|
|
15
|
-
return
|
|
15
|
+
return chunkOIYG5D2I_js.createError(
|
|
16
16
|
context,
|
|
17
17
|
"INVALID_NOT_MATCHES",
|
|
18
18
|
message || `Must not match ${fieldName}`,
|
|
@@ -24,15 +24,15 @@ var notMatchesValidator = (value, params, context) => {
|
|
|
24
24
|
|
|
25
25
|
// src/validators/common/greaterThan.ts
|
|
26
26
|
var greaterThanValidator = (value, params, context) => {
|
|
27
|
-
if (
|
|
27
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
28
28
|
const fieldName = params?.field;
|
|
29
29
|
const soft = params?.soft;
|
|
30
30
|
const message = params?.message;
|
|
31
|
-
if (!
|
|
31
|
+
if (!chunkOIYG5D2I_js.isNumber(value) || !fieldName) return null;
|
|
32
32
|
const root = context.root;
|
|
33
33
|
const otherValue = root?.[fieldName];
|
|
34
|
-
if (
|
|
35
|
-
return
|
|
34
|
+
if (chunkOIYG5D2I_js.isNumber(otherValue) && value <= otherValue) {
|
|
35
|
+
return chunkOIYG5D2I_js.createError(
|
|
36
36
|
context,
|
|
37
37
|
"INVALID_GREATER_THAN",
|
|
38
38
|
message || `Must be greater than ${fieldName}`,
|
|
@@ -44,15 +44,15 @@ var greaterThanValidator = (value, params, context) => {
|
|
|
44
44
|
|
|
45
45
|
// src/validators/common/lessThan.ts
|
|
46
46
|
var lessThanValidator = (value, params, context) => {
|
|
47
|
-
if (
|
|
47
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
48
48
|
const fieldName = params?.field;
|
|
49
49
|
const soft = params?.soft;
|
|
50
50
|
const message = params?.message;
|
|
51
|
-
if (!
|
|
51
|
+
if (!chunkOIYG5D2I_js.isNumber(value) || !fieldName) return null;
|
|
52
52
|
const root = context.root;
|
|
53
53
|
const otherValue = root?.[fieldName];
|
|
54
|
-
if (
|
|
55
|
-
return
|
|
54
|
+
if (chunkOIYG5D2I_js.isNumber(otherValue) && value >= otherValue) {
|
|
55
|
+
return chunkOIYG5D2I_js.createError(
|
|
56
56
|
context,
|
|
57
57
|
"INVALID_LESS_THAN",
|
|
58
58
|
message || `Must be less than ${fieldName}`,
|
|
@@ -78,15 +78,15 @@ var whenValidator = (value, params, context) => {
|
|
|
78
78
|
|
|
79
79
|
// src/validators/common/dependsOn.ts
|
|
80
80
|
var dependsOnValidator = (value, params, context) => {
|
|
81
|
-
if (
|
|
81
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
82
82
|
const fieldName = params?.field;
|
|
83
83
|
const soft = params?.soft;
|
|
84
84
|
const message = params?.message;
|
|
85
85
|
if (!fieldName) return null;
|
|
86
86
|
const root = context.root;
|
|
87
87
|
const otherValue = root?.[fieldName];
|
|
88
|
-
if (
|
|
89
|
-
return
|
|
88
|
+
if (chunkOIYG5D2I_js.isEmpty(otherValue)) {
|
|
89
|
+
return chunkOIYG5D2I_js.createError(
|
|
90
90
|
context,
|
|
91
91
|
"INVALID_DEPENDS_ON",
|
|
92
92
|
message || `This field requires ${fieldName} to be set`,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkOIYG5D2I_js = require('./chunk-OIYG5D2I.js');
|
|
4
4
|
|
|
5
5
|
// src/validators/number/port.ts
|
|
6
6
|
var portValidator = (value, params, context) => {
|
|
7
|
-
if (
|
|
7
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
8
8
|
const soft = params?.soft;
|
|
9
9
|
const message = params?.message;
|
|
10
|
-
if (!
|
|
10
|
+
if (!chunkOIYG5D2I_js.isNumber(value)) return null;
|
|
11
11
|
if (!Number.isInteger(value) || value < 0 || value > 65535) {
|
|
12
|
-
return
|
|
12
|
+
return chunkOIYG5D2I_js.createError(
|
|
13
13
|
context,
|
|
14
14
|
"INVALID_PORT",
|
|
15
15
|
message || "Must be a valid port number (0-65535)",
|
|
@@ -21,12 +21,12 @@ var portValidator = (value, params, context) => {
|
|
|
21
21
|
|
|
22
22
|
// src/validators/number/latitude.ts
|
|
23
23
|
var latitudeValidator = (value, params, context) => {
|
|
24
|
-
if (
|
|
24
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
25
25
|
const soft = params?.soft;
|
|
26
26
|
const message = params?.message;
|
|
27
|
-
if (!
|
|
27
|
+
if (!chunkOIYG5D2I_js.isNumber(value)) return null;
|
|
28
28
|
if (value < -90 || value > 90) {
|
|
29
|
-
return
|
|
29
|
+
return chunkOIYG5D2I_js.createError(
|
|
30
30
|
context,
|
|
31
31
|
"INVALID_LATITUDE",
|
|
32
32
|
message || "Latitude must be between -90 and 90",
|
|
@@ -38,12 +38,12 @@ var latitudeValidator = (value, params, context) => {
|
|
|
38
38
|
|
|
39
39
|
// src/validators/number/longitude.ts
|
|
40
40
|
var longitudeValidator = (value, params, context) => {
|
|
41
|
-
if (
|
|
41
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
42
42
|
const soft = params?.soft;
|
|
43
43
|
const message = params?.message;
|
|
44
|
-
if (!
|
|
44
|
+
if (!chunkOIYG5D2I_js.isNumber(value)) return null;
|
|
45
45
|
if (value < -180 || value > 180) {
|
|
46
|
-
return
|
|
46
|
+
return chunkOIYG5D2I_js.createError(
|
|
47
47
|
context,
|
|
48
48
|
"INVALID_LONGITUDE",
|
|
49
49
|
message || "Longitude must be between -180 and 180",
|
|
@@ -55,12 +55,12 @@ var longitudeValidator = (value, params, context) => {
|
|
|
55
55
|
|
|
56
56
|
// src/validators/number/percentage.ts
|
|
57
57
|
var percentageValidator = (value, params, context) => {
|
|
58
|
-
if (
|
|
58
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
59
59
|
const soft = params?.soft;
|
|
60
60
|
const message = params?.message;
|
|
61
|
-
if (!
|
|
61
|
+
if (!chunkOIYG5D2I_js.isNumber(value)) return null;
|
|
62
62
|
if (value < 0 || value > 100) {
|
|
63
|
-
return
|
|
63
|
+
return chunkOIYG5D2I_js.createError(
|
|
64
64
|
context,
|
|
65
65
|
"INVALID_PERCENTAGE",
|
|
66
66
|
message || "Percentage must be between 0 and 100",
|
|
@@ -72,14 +72,14 @@ var percentageValidator = (value, params, context) => {
|
|
|
72
72
|
|
|
73
73
|
// src/validators/number/between.ts
|
|
74
74
|
var betweenValidator = (value, params, context) => {
|
|
75
|
-
if (
|
|
75
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
76
76
|
const min = params?.min;
|
|
77
77
|
const max = params?.max;
|
|
78
78
|
const soft = params?.soft;
|
|
79
79
|
const message = params?.message;
|
|
80
|
-
if (!
|
|
80
|
+
if (!chunkOIYG5D2I_js.isNumber(value)) return null;
|
|
81
81
|
if (value < min || value > max) {
|
|
82
|
-
return
|
|
82
|
+
return chunkOIYG5D2I_js.createError(
|
|
83
83
|
context,
|
|
84
84
|
"INVALID_BETWEEN",
|
|
85
85
|
message || `Must be between ${min} and ${max}`,
|
|
@@ -91,13 +91,13 @@ var betweenValidator = (value, params, context) => {
|
|
|
91
91
|
|
|
92
92
|
// src/validators/number/divisibleBy.ts
|
|
93
93
|
var divisibleByValidator = (value, params, context) => {
|
|
94
|
-
if (
|
|
94
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
95
95
|
const divisor = params?.divisor;
|
|
96
96
|
const soft = params?.soft;
|
|
97
97
|
const message = params?.message;
|
|
98
|
-
if (!
|
|
98
|
+
if (!chunkOIYG5D2I_js.isNumber(value)) return null;
|
|
99
99
|
if (value % divisor !== 0) {
|
|
100
|
-
return
|
|
100
|
+
return chunkOIYG5D2I_js.createError(
|
|
101
101
|
context,
|
|
102
102
|
"INVALID_DIVISIBLE_BY",
|
|
103
103
|
message || `Must be divisible by ${divisor}`,
|
|
@@ -109,13 +109,13 @@ var divisibleByValidator = (value, params, context) => {
|
|
|
109
109
|
|
|
110
110
|
// src/validators/number/multipleOf.ts
|
|
111
111
|
var multipleOfValidator = (value, params, context) => {
|
|
112
|
-
if (
|
|
112
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
113
113
|
const multiple = params?.multiple;
|
|
114
114
|
const soft = params?.soft;
|
|
115
115
|
const message = params?.message;
|
|
116
|
-
if (!
|
|
116
|
+
if (!chunkOIYG5D2I_js.isNumber(value)) return null;
|
|
117
117
|
if (value % multiple !== 0) {
|
|
118
|
-
return
|
|
118
|
+
return chunkOIYG5D2I_js.createError(
|
|
119
119
|
context,
|
|
120
120
|
"INVALID_MULTIPLE_OF",
|
|
121
121
|
message || `Must be a multiple of ${multiple}`,
|
|
@@ -127,12 +127,12 @@ var multipleOfValidator = (value, params, context) => {
|
|
|
127
127
|
|
|
128
128
|
// src/validators/number/even.ts
|
|
129
129
|
var evenValidator = (value, params, context) => {
|
|
130
|
-
if (
|
|
130
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
131
131
|
const soft = params?.soft;
|
|
132
132
|
const message = params?.message;
|
|
133
|
-
if (!
|
|
133
|
+
if (!chunkOIYG5D2I_js.isNumber(value)) return null;
|
|
134
134
|
if (value % 2 !== 0) {
|
|
135
|
-
return
|
|
135
|
+
return chunkOIYG5D2I_js.createError(
|
|
136
136
|
context,
|
|
137
137
|
"INVALID_EVEN",
|
|
138
138
|
message || "Must be an even number",
|
|
@@ -144,12 +144,12 @@ var evenValidator = (value, params, context) => {
|
|
|
144
144
|
|
|
145
145
|
// src/validators/number/odd.ts
|
|
146
146
|
var oddValidator = (value, params, context) => {
|
|
147
|
-
if (
|
|
147
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
148
148
|
const soft = params?.soft;
|
|
149
149
|
const message = params?.message;
|
|
150
|
-
if (!
|
|
150
|
+
if (!chunkOIYG5D2I_js.isNumber(value)) return null;
|
|
151
151
|
if (value % 2 === 0) {
|
|
152
|
-
return
|
|
152
|
+
return chunkOIYG5D2I_js.createError(
|
|
153
153
|
context,
|
|
154
154
|
"INVALID_ODD",
|
|
155
155
|
message || "Must be an odd number",
|
|
@@ -161,12 +161,12 @@ var oddValidator = (value, params, context) => {
|
|
|
161
161
|
|
|
162
162
|
// src/validators/number/safe.ts
|
|
163
163
|
var safeValidator = (value, params, context) => {
|
|
164
|
-
if (
|
|
164
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
165
165
|
const soft = params?.soft;
|
|
166
166
|
const message = params?.message;
|
|
167
|
-
if (!
|
|
167
|
+
if (!chunkOIYG5D2I_js.isNumber(value)) return null;
|
|
168
168
|
if (!Number.isSafeInteger(value)) {
|
|
169
|
-
return
|
|
169
|
+
return chunkOIYG5D2I_js.createError(
|
|
170
170
|
context,
|
|
171
171
|
"INVALID_SAFE_INTEGER",
|
|
172
172
|
message || "Must be a safe integer",
|
|
@@ -178,12 +178,12 @@ var safeValidator = (value, params, context) => {
|
|
|
178
178
|
|
|
179
179
|
// src/validators/number/finite.ts
|
|
180
180
|
var finiteValidator = (value, params, context) => {
|
|
181
|
-
if (
|
|
181
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
182
182
|
const soft = params?.soft;
|
|
183
183
|
const message = params?.message;
|
|
184
|
-
if (!
|
|
184
|
+
if (!chunkOIYG5D2I_js.isNumber(value)) return null;
|
|
185
185
|
if (!Number.isFinite(value)) {
|
|
186
|
-
return
|
|
186
|
+
return chunkOIYG5D2I_js.createError(
|
|
187
187
|
context,
|
|
188
188
|
"INVALID_FINITE",
|
|
189
189
|
message || "Must be a finite number",
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkOIYG5D2I_js = require('./chunk-OIYG5D2I.js');
|
|
4
4
|
|
|
5
5
|
// src/validators/string/email.ts
|
|
6
6
|
var EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
7
7
|
var emailValidator = (value, params, context) => {
|
|
8
|
-
if (
|
|
8
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
9
9
|
const soft = params?.soft;
|
|
10
10
|
const message = params?.message;
|
|
11
|
-
if (!
|
|
12
|
-
return
|
|
11
|
+
if (!chunkOIYG5D2I_js.isString(value)) {
|
|
12
|
+
return chunkOIYG5D2I_js.createError(context, "INVALID_EMAIL", "Email must be a string", soft);
|
|
13
13
|
}
|
|
14
14
|
if (!EMAIL_REGEX.test(value)) {
|
|
15
|
-
return
|
|
15
|
+
return chunkOIYG5D2I_js.createError(
|
|
16
16
|
context,
|
|
17
17
|
"INVALID_EMAIL",
|
|
18
18
|
message || "Invalid email address",
|
|
@@ -24,17 +24,17 @@ var emailValidator = (value, params, context) => {
|
|
|
24
24
|
|
|
25
25
|
// src/validators/string/url.ts
|
|
26
26
|
var urlValidator = (value, params, context) => {
|
|
27
|
-
if (
|
|
27
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
28
28
|
const soft = params?.soft;
|
|
29
29
|
const message = params?.message;
|
|
30
|
-
if (!
|
|
31
|
-
return
|
|
30
|
+
if (!chunkOIYG5D2I_js.isString(value)) {
|
|
31
|
+
return chunkOIYG5D2I_js.createError(context, "INVALID_URL", "URL must be a string", soft);
|
|
32
32
|
}
|
|
33
33
|
try {
|
|
34
34
|
new URL(value);
|
|
35
35
|
return null;
|
|
36
36
|
} catch {
|
|
37
|
-
return
|
|
37
|
+
return chunkOIYG5D2I_js.createError(
|
|
38
38
|
context,
|
|
39
39
|
"INVALID_URL",
|
|
40
40
|
message || "Invalid URL format",
|
|
@@ -46,14 +46,14 @@ var urlValidator = (value, params, context) => {
|
|
|
46
46
|
// src/validators/string/ipAddress.ts
|
|
47
47
|
var IPV4_REGEX = /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
|
48
48
|
var ipAddressValidator = (value, params, context) => {
|
|
49
|
-
if (
|
|
49
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
50
50
|
const soft = params?.soft;
|
|
51
51
|
const message = params?.message;
|
|
52
|
-
if (!
|
|
53
|
-
return
|
|
52
|
+
if (!chunkOIYG5D2I_js.isString(value)) {
|
|
53
|
+
return chunkOIYG5D2I_js.createError(context, "INVALID_IP", "IP address must be a string", soft);
|
|
54
54
|
}
|
|
55
55
|
if (!IPV4_REGEX.test(value)) {
|
|
56
|
-
return
|
|
56
|
+
return chunkOIYG5D2I_js.createError(
|
|
57
57
|
context,
|
|
58
58
|
"INVALID_IP",
|
|
59
59
|
message || "Invalid IP address format",
|
|
@@ -66,14 +66,14 @@ var ipAddressValidator = (value, params, context) => {
|
|
|
66
66
|
// src/validators/string/ipv6.ts
|
|
67
67
|
var IPV6_REGEX = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|::)$/;
|
|
68
68
|
var ipv6Validator = (value, params, context) => {
|
|
69
|
-
if (
|
|
69
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
70
70
|
const soft = params?.soft;
|
|
71
71
|
const message = params?.message;
|
|
72
|
-
if (!
|
|
73
|
-
return
|
|
72
|
+
if (!chunkOIYG5D2I_js.isString(value)) {
|
|
73
|
+
return chunkOIYG5D2I_js.createError(context, "INVALID_IPV6", "IPv6 address must be a string", soft);
|
|
74
74
|
}
|
|
75
75
|
if (!IPV6_REGEX.test(value)) {
|
|
76
|
-
return
|
|
76
|
+
return chunkOIYG5D2I_js.createError(
|
|
77
77
|
context,
|
|
78
78
|
"INVALID_IPV6",
|
|
79
79
|
message || "Invalid IPv6 address format",
|
|
@@ -86,14 +86,14 @@ var ipv6Validator = (value, params, context) => {
|
|
|
86
86
|
// src/validators/string/alpha.ts
|
|
87
87
|
var ALPHA_REGEX = /^[a-zA-Z]+$/;
|
|
88
88
|
var alphaValidator = (value, params, context) => {
|
|
89
|
-
if (
|
|
89
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
90
90
|
const soft = params?.soft;
|
|
91
91
|
const message = params?.message;
|
|
92
|
-
if (!
|
|
93
|
-
return
|
|
92
|
+
if (!chunkOIYG5D2I_js.isString(value)) {
|
|
93
|
+
return chunkOIYG5D2I_js.createError(context, "INVALID_ALPHA", "Value must be a string", soft);
|
|
94
94
|
}
|
|
95
95
|
if (!ALPHA_REGEX.test(value)) {
|
|
96
|
-
return
|
|
96
|
+
return chunkOIYG5D2I_js.createError(
|
|
97
97
|
context,
|
|
98
98
|
"INVALID_ALPHA",
|
|
99
99
|
message || "Must contain only letters",
|
|
@@ -106,14 +106,14 @@ var alphaValidator = (value, params, context) => {
|
|
|
106
106
|
// src/validators/string/alphanumeric.ts
|
|
107
107
|
var ALPHANUMERIC_REGEX = /^[a-zA-Z0-9]+$/;
|
|
108
108
|
var alphanumericValidator = (value, params, context) => {
|
|
109
|
-
if (
|
|
109
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
110
110
|
const soft = params?.soft;
|
|
111
111
|
const message = params?.message;
|
|
112
|
-
if (!
|
|
113
|
-
return
|
|
112
|
+
if (!chunkOIYG5D2I_js.isString(value)) {
|
|
113
|
+
return chunkOIYG5D2I_js.createError(context, "INVALID_ALPHANUMERIC", "Value must be a string", soft);
|
|
114
114
|
}
|
|
115
115
|
if (!ALPHANUMERIC_REGEX.test(value)) {
|
|
116
|
-
return
|
|
116
|
+
return chunkOIYG5D2I_js.createError(
|
|
117
117
|
context,
|
|
118
118
|
"INVALID_ALPHANUMERIC",
|
|
119
119
|
message || "Must contain only letters and numbers",
|
|
@@ -126,14 +126,14 @@ var alphanumericValidator = (value, params, context) => {
|
|
|
126
126
|
// src/validators/string/numeric.ts
|
|
127
127
|
var NUMERIC_REGEX = /^[0-9]+$/;
|
|
128
128
|
var numericValidator = (value, params, context) => {
|
|
129
|
-
if (
|
|
129
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
130
130
|
const soft = params?.soft;
|
|
131
131
|
const message = params?.message;
|
|
132
|
-
if (!
|
|
133
|
-
return
|
|
132
|
+
if (!chunkOIYG5D2I_js.isString(value)) {
|
|
133
|
+
return chunkOIYG5D2I_js.createError(context, "INVALID_NUMERIC", "Value must be a string", soft);
|
|
134
134
|
}
|
|
135
135
|
if (!NUMERIC_REGEX.test(value)) {
|
|
136
|
-
return
|
|
136
|
+
return chunkOIYG5D2I_js.createError(
|
|
137
137
|
context,
|
|
138
138
|
"INVALID_NUMERIC",
|
|
139
139
|
message || "Must contain only numbers",
|
|
@@ -145,14 +145,14 @@ var numericValidator = (value, params, context) => {
|
|
|
145
145
|
|
|
146
146
|
// src/validators/string/lowercase.ts
|
|
147
147
|
var lowercaseValidator = (value, params, context) => {
|
|
148
|
-
if (
|
|
148
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
149
149
|
const soft = params?.soft;
|
|
150
150
|
const message = params?.message;
|
|
151
|
-
if (!
|
|
152
|
-
return
|
|
151
|
+
if (!chunkOIYG5D2I_js.isString(value)) {
|
|
152
|
+
return chunkOIYG5D2I_js.createError(context, "INVALID_LOWERCASE", "Value must be a string", soft);
|
|
153
153
|
}
|
|
154
154
|
if (value !== value.toLowerCase()) {
|
|
155
|
-
return
|
|
155
|
+
return chunkOIYG5D2I_js.createError(
|
|
156
156
|
context,
|
|
157
157
|
"INVALID_LOWERCASE",
|
|
158
158
|
message || "Must be lowercase",
|
|
@@ -164,14 +164,14 @@ var lowercaseValidator = (value, params, context) => {
|
|
|
164
164
|
|
|
165
165
|
// src/validators/string/uppercase.ts
|
|
166
166
|
var uppercaseValidator = (value, params, context) => {
|
|
167
|
-
if (
|
|
167
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
168
168
|
const soft = params?.soft;
|
|
169
169
|
const message = params?.message;
|
|
170
|
-
if (!
|
|
171
|
-
return
|
|
170
|
+
if (!chunkOIYG5D2I_js.isString(value)) {
|
|
171
|
+
return chunkOIYG5D2I_js.createError(context, "INVALID_UPPERCASE", "Value must be a string", soft);
|
|
172
172
|
}
|
|
173
173
|
if (value !== value.toUpperCase()) {
|
|
174
|
-
return
|
|
174
|
+
return chunkOIYG5D2I_js.createError(
|
|
175
175
|
context,
|
|
176
176
|
"INVALID_UPPERCASE",
|
|
177
177
|
message || "Must be uppercase",
|
|
@@ -184,14 +184,14 @@ var uppercaseValidator = (value, params, context) => {
|
|
|
184
184
|
// src/validators/string/slug.ts
|
|
185
185
|
var SLUG_REGEX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
186
186
|
var slugValidator = (value, params, context) => {
|
|
187
|
-
if (
|
|
187
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
188
188
|
const soft = params?.soft;
|
|
189
189
|
const message = params?.message;
|
|
190
|
-
if (!
|
|
191
|
-
return
|
|
190
|
+
if (!chunkOIYG5D2I_js.isString(value)) {
|
|
191
|
+
return chunkOIYG5D2I_js.createError(context, "INVALID_SLUG", "Slug must be a string", soft);
|
|
192
192
|
}
|
|
193
193
|
if (!SLUG_REGEX.test(value)) {
|
|
194
|
-
return
|
|
194
|
+
return chunkOIYG5D2I_js.createError(
|
|
195
195
|
context,
|
|
196
196
|
"INVALID_SLUG",
|
|
197
197
|
message || "Must be a valid URL slug (lowercase, numbers, hyphens)",
|
|
@@ -204,14 +204,14 @@ var slugValidator = (value, params, context) => {
|
|
|
204
204
|
// src/validators/string/hex.ts
|
|
205
205
|
var HEX_REGEX = /^(0x)?[0-9a-fA-F]+$/;
|
|
206
206
|
var hexValidator = (value, params, context) => {
|
|
207
|
-
if (
|
|
207
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
208
208
|
const soft = params?.soft;
|
|
209
209
|
const message = params?.message;
|
|
210
|
-
if (!
|
|
211
|
-
return
|
|
210
|
+
if (!chunkOIYG5D2I_js.isString(value)) {
|
|
211
|
+
return chunkOIYG5D2I_js.createError(context, "INVALID_HEX", "Hex value must be a string", soft);
|
|
212
212
|
}
|
|
213
213
|
if (!HEX_REGEX.test(value)) {
|
|
214
|
-
return
|
|
214
|
+
return chunkOIYG5D2I_js.createError(
|
|
215
215
|
context,
|
|
216
216
|
"INVALID_HEX",
|
|
217
217
|
message || "Must be a valid hexadecimal string",
|
|
@@ -224,14 +224,14 @@ var hexValidator = (value, params, context) => {
|
|
|
224
224
|
// src/validators/string/base64.ts
|
|
225
225
|
var BASE64_REGEX = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
226
226
|
var base64Validator = (value, params, context) => {
|
|
227
|
-
if (
|
|
227
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
228
228
|
const soft = params?.soft;
|
|
229
229
|
const message = params?.message;
|
|
230
|
-
if (!
|
|
231
|
-
return
|
|
230
|
+
if (!chunkOIYG5D2I_js.isString(value)) {
|
|
231
|
+
return chunkOIYG5D2I_js.createError(context, "INVALID_BASE64", "Base64 value must be a string", soft);
|
|
232
232
|
}
|
|
233
233
|
if (!BASE64_REGEX.test(value)) {
|
|
234
|
-
return
|
|
234
|
+
return chunkOIYG5D2I_js.createError(
|
|
235
235
|
context,
|
|
236
236
|
"INVALID_BASE64",
|
|
237
237
|
message || "Must be a valid base64 string",
|
|
@@ -243,17 +243,17 @@ var base64Validator = (value, params, context) => {
|
|
|
243
243
|
|
|
244
244
|
// src/validators/string/json.ts
|
|
245
245
|
var jsonValidator = (value, params, context) => {
|
|
246
|
-
if (
|
|
246
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
247
247
|
const soft = params?.soft;
|
|
248
248
|
const message = params?.message;
|
|
249
|
-
if (!
|
|
250
|
-
return
|
|
249
|
+
if (!chunkOIYG5D2I_js.isString(value)) {
|
|
250
|
+
return chunkOIYG5D2I_js.createError(context, "INVALID_JSON", "JSON value must be a string", soft);
|
|
251
251
|
}
|
|
252
252
|
try {
|
|
253
253
|
JSON.parse(value);
|
|
254
254
|
return null;
|
|
255
255
|
} catch {
|
|
256
|
-
return
|
|
256
|
+
return chunkOIYG5D2I_js.createError(
|
|
257
257
|
context,
|
|
258
258
|
"INVALID_JSON",
|
|
259
259
|
message || "Must be valid JSON",
|
|
@@ -264,13 +264,13 @@ var jsonValidator = (value, params, context) => {
|
|
|
264
264
|
|
|
265
265
|
// src/validators/string/length.ts
|
|
266
266
|
var lengthValidator = (value, params, context) => {
|
|
267
|
-
if (
|
|
267
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
268
268
|
const length = params?.length;
|
|
269
269
|
const soft = params?.soft;
|
|
270
270
|
const message = params?.message;
|
|
271
|
-
if (!
|
|
271
|
+
if (!chunkOIYG5D2I_js.isString(value)) return null;
|
|
272
272
|
if (value.length !== length) {
|
|
273
|
-
return
|
|
273
|
+
return chunkOIYG5D2I_js.createError(
|
|
274
274
|
context,
|
|
275
275
|
"INVALID_LENGTH",
|
|
276
276
|
message || `Must be exactly ${length} characters`,
|
|
@@ -282,13 +282,13 @@ var lengthValidator = (value, params, context) => {
|
|
|
282
282
|
|
|
283
283
|
// src/validators/string/contains.ts
|
|
284
284
|
var containsValidator = (value, params, context) => {
|
|
285
|
-
if (
|
|
285
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
286
286
|
const substring = params?.substring;
|
|
287
287
|
const soft = params?.soft;
|
|
288
288
|
const message = params?.message;
|
|
289
|
-
if (!
|
|
289
|
+
if (!chunkOIYG5D2I_js.isString(value)) return null;
|
|
290
290
|
if (!value.includes(substring)) {
|
|
291
|
-
return
|
|
291
|
+
return chunkOIYG5D2I_js.createError(
|
|
292
292
|
context,
|
|
293
293
|
"INVALID_CONTAINS",
|
|
294
294
|
message || `Must contain "${substring}"`,
|
|
@@ -300,13 +300,13 @@ var containsValidator = (value, params, context) => {
|
|
|
300
300
|
|
|
301
301
|
// src/validators/string/startsWith.ts
|
|
302
302
|
var startsWithValidator = (value, params, context) => {
|
|
303
|
-
if (
|
|
303
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
304
304
|
const prefix = params?.prefix;
|
|
305
305
|
const soft = params?.soft;
|
|
306
306
|
const message = params?.message;
|
|
307
|
-
if (!
|
|
307
|
+
if (!chunkOIYG5D2I_js.isString(value)) return null;
|
|
308
308
|
if (!value.startsWith(prefix)) {
|
|
309
|
-
return
|
|
309
|
+
return chunkOIYG5D2I_js.createError(
|
|
310
310
|
context,
|
|
311
311
|
"INVALID_STARTS_WITH",
|
|
312
312
|
message || `Must start with "${prefix}"`,
|
|
@@ -318,13 +318,13 @@ var startsWithValidator = (value, params, context) => {
|
|
|
318
318
|
|
|
319
319
|
// src/validators/string/endsWith.ts
|
|
320
320
|
var endsWithValidator = (value, params, context) => {
|
|
321
|
-
if (
|
|
321
|
+
if (chunkOIYG5D2I_js.isEmpty(value)) return null;
|
|
322
322
|
const suffix = params?.suffix;
|
|
323
323
|
const soft = params?.soft;
|
|
324
324
|
const message = params?.message;
|
|
325
|
-
if (!
|
|
325
|
+
if (!chunkOIYG5D2I_js.isString(value)) return null;
|
|
326
326
|
if (!value.endsWith(suffix)) {
|
|
327
|
-
return
|
|
327
|
+
return chunkOIYG5D2I_js.createError(
|
|
328
328
|
context,
|
|
329
329
|
"INVALID_ENDS_WITH",
|
|
330
330
|
message || `Must end with "${suffix}"`,
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// src/validators/utils.ts
|
|
2
|
-
function createError(context, code, message, soft = false) {
|
|
2
|
+
function createError(context, code, message, soft = false, received, expected) {
|
|
3
3
|
return {
|
|
4
4
|
field: context.path,
|
|
5
5
|
code,
|
|
6
6
|
message,
|
|
7
|
-
severity: soft ? "soft" : "hard"
|
|
7
|
+
severity: soft ? "soft" : "hard",
|
|
8
|
+
received,
|
|
9
|
+
expected
|
|
8
10
|
};
|
|
9
11
|
}
|
|
10
12
|
function isEmpty(value) {
|