@ooneex/validation 0.0.12 → 0.0.14
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/dist/constraints/index.js +348 -2
- package/dist/constraints/index.js.map +2 -2
- package/dist/index.js +14 -2
- package/dist/index.js.map +2 -2
- package/dist/shared/chunk-0m070e63.js +71 -0
- package/dist/shared/{chunk-bn4vhq39.js.map → chunk-0m070e63.js.map} +2 -2
- package/package.json +5 -4
- package/dist/shared/chunk-bn4vhq39.js +0 -4
|
@@ -1,3 +1,349 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
Assert,
|
|
3
|
+
Validation
|
|
4
|
+
} from "../shared/chunk-0m070e63.js";
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
// src/constraints/AssertAppEnv.ts
|
|
7
|
+
import { Environment } from "@ooneex/app-env";
|
|
8
|
+
var environments = Object.values(Environment);
|
|
9
|
+
|
|
10
|
+
class AssertAppEnv extends Validation {
|
|
11
|
+
getConstraint() {
|
|
12
|
+
return Assert(`"${environments.join('" | "')}"`);
|
|
13
|
+
}
|
|
14
|
+
getErrorMessage() {
|
|
15
|
+
return `Must be a valid environment (${environments.join(", ")})`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// src/constraints/AssertChatQuery.ts
|
|
19
|
+
var CHAT_QUERY_MIN_LENGTH = 1;
|
|
20
|
+
var CHAT_QUERY_MAX_LENGTH = 2000;
|
|
21
|
+
var CHAT_QUERY_FORBIDDEN_PATTERNS = [
|
|
22
|
+
/<script[^>]*>.*?<\/script>/gi,
|
|
23
|
+
/<\/?[a-zA-Z][^>]*>/g,
|
|
24
|
+
/javascript:/gi,
|
|
25
|
+
/data:/gi,
|
|
26
|
+
/vbscript:/gi
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
class AssertChatQuery extends Validation {
|
|
30
|
+
getConstraint() {
|
|
31
|
+
return Assert(`${CHAT_QUERY_MIN_LENGTH} <= string <= ${CHAT_QUERY_MAX_LENGTH}`);
|
|
32
|
+
}
|
|
33
|
+
getErrorMessage() {
|
|
34
|
+
return "Chat query must be between 1 and 2000 characters and cannot contain HTML tags, scripts, or unsafe protocols";
|
|
35
|
+
}
|
|
36
|
+
validate(data, constraint) {
|
|
37
|
+
const basicValidation = super.validate(data, constraint);
|
|
38
|
+
if (!basicValidation.isValid) {
|
|
39
|
+
return basicValidation;
|
|
40
|
+
}
|
|
41
|
+
const query = data;
|
|
42
|
+
for (const pattern of CHAT_QUERY_FORBIDDEN_PATTERNS) {
|
|
43
|
+
pattern.lastIndex = 0;
|
|
44
|
+
if (pattern.test(query)) {
|
|
45
|
+
return {
|
|
46
|
+
isValid: false,
|
|
47
|
+
message: this.getErrorMessage() || "Invalid chat query"
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
isValid: true
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// src/constraints/AssertCountryCode.ts
|
|
57
|
+
class AssertCountryCode extends Validation {
|
|
58
|
+
getConstraint() {
|
|
59
|
+
return Assert("2 <= string <= 2 & /^[A-Z]{2}$/");
|
|
60
|
+
}
|
|
61
|
+
getErrorMessage() {
|
|
62
|
+
return "Country code must be a 2-character uppercase ISO 3166-1 alpha-2 code";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// src/constraints/AssertCurrency.ts
|
|
66
|
+
import { CURRENCIES } from "@ooneex/currencies";
|
|
67
|
+
var VALID_CURRENCY_CODES = CURRENCIES.map((currency) => currency.code);
|
|
68
|
+
|
|
69
|
+
class AssertCurrency extends Validation {
|
|
70
|
+
getConstraint() {
|
|
71
|
+
return Assert(`"${VALID_CURRENCY_CODES.join('" | "')}" & /^[A-Z]{3}$/`);
|
|
72
|
+
}
|
|
73
|
+
getErrorMessage() {
|
|
74
|
+
return "Currency code must be a valid ISO 4217 currency code (3 uppercase letters)";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// src/constraints/AssertEmail.ts
|
|
78
|
+
class AssertEmail extends Validation {
|
|
79
|
+
getConstraint() {
|
|
80
|
+
return Assert("string.email");
|
|
81
|
+
}
|
|
82
|
+
getErrorMessage() {
|
|
83
|
+
return "Must be a valid email address";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// src/constraints/AssertFirstName.ts
|
|
87
|
+
class AssertFirstName extends Validation {
|
|
88
|
+
getConstraint() {
|
|
89
|
+
return Assert("1 <= string <= 50 & /^[a-zA-Z\\s'-]+$/");
|
|
90
|
+
}
|
|
91
|
+
getErrorMessage() {
|
|
92
|
+
return "First name must be between 1 and 50 characters and contain only letters, spaces, hyphens, and apostrophes";
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// src/constraints/AssertHexaColor.ts
|
|
96
|
+
var HEXA_COLOR_3_DIGIT_REGEX = /^#[0-9A-Fa-f]{3}$/;
|
|
97
|
+
var HEXA_COLOR_6_DIGIT_REGEX = /^#[0-9A-Fa-f]{6}$/;
|
|
98
|
+
|
|
99
|
+
class AssertHexaColor extends Validation {
|
|
100
|
+
getConstraint() {
|
|
101
|
+
return Assert("string");
|
|
102
|
+
}
|
|
103
|
+
getErrorMessage() {
|
|
104
|
+
return "Value must be a valid hexadecimal color (e.g., #fff, #ffffff, #A1B2C3)";
|
|
105
|
+
}
|
|
106
|
+
validate(data, constraint) {
|
|
107
|
+
const basicValidation = super.validate(data, constraint);
|
|
108
|
+
if (!basicValidation.isValid) {
|
|
109
|
+
return basicValidation;
|
|
110
|
+
}
|
|
111
|
+
const color = data;
|
|
112
|
+
const is3DigitHex = HEXA_COLOR_3_DIGIT_REGEX.test(color);
|
|
113
|
+
const is6DigitHex = HEXA_COLOR_6_DIGIT_REGEX.test(color);
|
|
114
|
+
if (!is3DigitHex && !is6DigitHex) {
|
|
115
|
+
return {
|
|
116
|
+
isValid: false,
|
|
117
|
+
message: this.getErrorMessage() || "Invalid hexadecimal color"
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
isValid: true
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// src/constraints/AssertHostname.ts
|
|
126
|
+
class AssertHostname extends Validation {
|
|
127
|
+
getConstraint() {
|
|
128
|
+
return Assert(/^$|^((25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\.){3}(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$|^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z]{2,})*$/);
|
|
129
|
+
}
|
|
130
|
+
getErrorMessage() {
|
|
131
|
+
return "Must be a valid hostname or IP address";
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// src/constraints/AssertId.ts
|
|
135
|
+
var ID_REGEX = /^[0-9a-f]+$/;
|
|
136
|
+
var DEFAULT_ID_LENGTH = 25;
|
|
137
|
+
|
|
138
|
+
class AssertId extends Validation {
|
|
139
|
+
getConstraint() {
|
|
140
|
+
return Assert(`${DEFAULT_ID_LENGTH} <= string <= ${DEFAULT_ID_LENGTH}`);
|
|
141
|
+
}
|
|
142
|
+
getErrorMessage() {
|
|
143
|
+
return "ID must be exactly 25 characters long and contain only lowercase hexadecimal characters (0-9, a-f)";
|
|
144
|
+
}
|
|
145
|
+
validate(data, constraint) {
|
|
146
|
+
const basicValidation = super.validate(data, constraint);
|
|
147
|
+
if (!basicValidation.isValid) {
|
|
148
|
+
return basicValidation;
|
|
149
|
+
}
|
|
150
|
+
const id = data;
|
|
151
|
+
if (!ID_REGEX.test(id)) {
|
|
152
|
+
return {
|
|
153
|
+
isValid: false,
|
|
154
|
+
message: this.getErrorMessage() || "Invalid ID format"
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
isValid: true
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// src/constraints/AssertLastName.ts
|
|
163
|
+
class AssertLastName extends Validation {
|
|
164
|
+
getConstraint() {
|
|
165
|
+
return Assert("1 <= string <= 50 & /^[a-zA-Z\\s'-]+$/");
|
|
166
|
+
}
|
|
167
|
+
getErrorMessage() {
|
|
168
|
+
return "Last name must be between 1 and 50 characters and contain only letters, spaces, hyphens, and apostrophes";
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// src/constraints/AssertLocale.ts
|
|
172
|
+
import { locales } from "@ooneex/translation";
|
|
173
|
+
class AssertLocale extends Validation {
|
|
174
|
+
getConstraint() {
|
|
175
|
+
return Assert(`"${locales.join('" | "')}"`);
|
|
176
|
+
}
|
|
177
|
+
getErrorMessage() {
|
|
178
|
+
return "Locale must be a valid locale code";
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// src/constraints/AssertName.ts
|
|
182
|
+
var NAME_MIN_LENGTH = 1;
|
|
183
|
+
var NAME_MAX_LENGTH = 50;
|
|
184
|
+
var NAME_REGEX = /^[a-zA-ZÀ-ÿĀ-žА-я\u4e00-\u9fff\s\-'0-9.]+$/;
|
|
185
|
+
|
|
186
|
+
class AssertName extends Validation {
|
|
187
|
+
getConstraint() {
|
|
188
|
+
return Assert(`${NAME_MIN_LENGTH} <= string <= ${NAME_MAX_LENGTH}`);
|
|
189
|
+
}
|
|
190
|
+
getErrorMessage() {
|
|
191
|
+
return "Name must be between 1 and 50 characters and contain only letters, numbers, spaces, hyphens, apostrophes, and periods";
|
|
192
|
+
}
|
|
193
|
+
validate(data, constraint) {
|
|
194
|
+
const basicValidation = super.validate(data, constraint);
|
|
195
|
+
if (!basicValidation.isValid) {
|
|
196
|
+
return basicValidation;
|
|
197
|
+
}
|
|
198
|
+
const name = data;
|
|
199
|
+
if (name.trim() !== name) {
|
|
200
|
+
return {
|
|
201
|
+
isValid: false,
|
|
202
|
+
message: this.getErrorMessage() || "Invalid name format"
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
if (!NAME_REGEX.test(name)) {
|
|
206
|
+
return {
|
|
207
|
+
isValid: false,
|
|
208
|
+
message: this.getErrorMessage() || "Invalid name format"
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
if (name.includes(".") && !name.match(/\.\s/)) {
|
|
212
|
+
return {
|
|
213
|
+
isValid: false,
|
|
214
|
+
message: this.getErrorMessage() || "Invalid name format"
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
isValid: true
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// src/constraints/AssertPort.ts
|
|
223
|
+
class AssertPort extends Validation {
|
|
224
|
+
getConstraint() {
|
|
225
|
+
return Assert("1 <= number.integer <= 65535");
|
|
226
|
+
}
|
|
227
|
+
getErrorMessage() {
|
|
228
|
+
return "Must be a valid port number (1-65535)";
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
// src/constraints/AssertUrl.ts
|
|
232
|
+
var URL_MAX_LENGTH = 2083;
|
|
233
|
+
var URL_REGEX = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .~-]*)*\/?(\?[&a-z\d%_.~+=-]*)?(#[-a-z\d_]*)?$/i;
|
|
234
|
+
var STRICT_URL_REGEX = /^https?:\/\/(?:[-\w.])+(?::[0-9]+)?(?:\/(?:[\w/_.])*(?:\?(?:[\w&=%.])*)?(?:#(?:[\w.])*)?)?$/;
|
|
235
|
+
|
|
236
|
+
class AssertUrl extends Validation {
|
|
237
|
+
getConstraint() {
|
|
238
|
+
return Assert(`1 <= string <= ${URL_MAX_LENGTH}`);
|
|
239
|
+
}
|
|
240
|
+
getErrorMessage() {
|
|
241
|
+
return `URL must be between 1 and ${URL_MAX_LENGTH} characters and follow a valid URL format (e.g., https://example.com, http://sub.domain.co.uk/path)`;
|
|
242
|
+
}
|
|
243
|
+
validate(data, constraint) {
|
|
244
|
+
const basicValidation = super.validate(data, constraint);
|
|
245
|
+
if (!basicValidation.isValid) {
|
|
246
|
+
return basicValidation;
|
|
247
|
+
}
|
|
248
|
+
const url = data;
|
|
249
|
+
if (url.match(/^(ftp|file|mailto|telnet|ssh|gopher):/i)) {
|
|
250
|
+
return {
|
|
251
|
+
isValid: false,
|
|
252
|
+
message: this.getErrorMessage() || "Invalid URL format"
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
if (url.includes("://") && !url.match(/^https?:\/\//i)) {
|
|
256
|
+
return {
|
|
257
|
+
isValid: false,
|
|
258
|
+
message: this.getErrorMessage() || "Invalid URL format"
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
if (url.trim() !== url) {
|
|
262
|
+
return {
|
|
263
|
+
isValid: false,
|
|
264
|
+
message: this.getErrorMessage() || "Invalid URL format"
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
if (url.includes("..") || url.startsWith(".") || url.includes("/.") || url.endsWith(".")) {
|
|
268
|
+
return {
|
|
269
|
+
isValid: false,
|
|
270
|
+
message: this.getErrorMessage() || "Invalid URL format"
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
if (!URL_REGEX.test(url)) {
|
|
274
|
+
return {
|
|
275
|
+
isValid: false,
|
|
276
|
+
message: this.getErrorMessage() || "Invalid URL format"
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
return {
|
|
280
|
+
isValid: true
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
validateStrict(data) {
|
|
284
|
+
const basicValidation = super.validate(data);
|
|
285
|
+
if (!basicValidation.isValid) {
|
|
286
|
+
return basicValidation;
|
|
287
|
+
}
|
|
288
|
+
const url = data;
|
|
289
|
+
if (!STRICT_URL_REGEX.test(url)) {
|
|
290
|
+
return {
|
|
291
|
+
isValid: false,
|
|
292
|
+
message: "URL must include protocol (http:// or https://) and follow strict URL format"
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
296
|
+
isValid: true
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// src/constraints/AssertYoutubeUrl.ts
|
|
301
|
+
var YOUTUBE_URL_PATTERNS = [
|
|
302
|
+
/^https?:\/\/(www\.)?youtube\.com\/watch\?v=[A-Za-z0-9_-]+$/,
|
|
303
|
+
/^https?:\/\/youtu\.be\/[A-Za-z0-9_-]+$/
|
|
304
|
+
];
|
|
305
|
+
|
|
306
|
+
class AssertYoutubeUrl extends Validation {
|
|
307
|
+
getConstraint() {
|
|
308
|
+
return Assert("string");
|
|
309
|
+
}
|
|
310
|
+
getErrorMessage() {
|
|
311
|
+
return "Must be a valid YouTube URL (e.g., https://youtube.com/watch?v=dQw4w9WgXcQ or https://youtu.be/dQw4w9WgXcQ)";
|
|
312
|
+
}
|
|
313
|
+
validate(data, constraint) {
|
|
314
|
+
const basicValidation = super.validate(data, constraint);
|
|
315
|
+
if (!basicValidation.isValid) {
|
|
316
|
+
return basicValidation;
|
|
317
|
+
}
|
|
318
|
+
const url = data;
|
|
319
|
+
const isValidYouTubeUrl = YOUTUBE_URL_PATTERNS.some((pattern) => pattern.test(url));
|
|
320
|
+
if (!isValidYouTubeUrl) {
|
|
321
|
+
return {
|
|
322
|
+
isValid: false,
|
|
323
|
+
message: this.getErrorMessage() || "Invalid YouTube URL"
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
isValid: true
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
export {
|
|
332
|
+
AssertYoutubeUrl,
|
|
333
|
+
AssertUrl,
|
|
334
|
+
AssertPort,
|
|
335
|
+
AssertName,
|
|
336
|
+
AssertLocale,
|
|
337
|
+
AssertLastName,
|
|
338
|
+
AssertId,
|
|
339
|
+
AssertHostname,
|
|
340
|
+
AssertHexaColor,
|
|
341
|
+
AssertFirstName,
|
|
342
|
+
AssertEmail,
|
|
343
|
+
AssertCurrency,
|
|
344
|
+
AssertCountryCode,
|
|
345
|
+
AssertChatQuery,
|
|
346
|
+
AssertAppEnv
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
//# debugId=CD2ED216799B256F64756E2164756E21
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"import type { AssertType, ValidationResultType } from \"../types\";\nimport { Assert } from \"../utils\";\nimport { Validation } from \"../Validation\";\n\nconst URL_MAX_LENGTH = 2083;\nconst URL_REGEX = /^(https?:\\/\\/)?([\\da-z.-]+)\\.([a-z.]{2,6})([/\\w .~-]*)*\\/?(\\?[&a-z\\d%_.~+=-]*)?(#[-a-z\\d_]*)?$/i;\n\nconst STRICT_URL_REGEX = /^https?:\\/\\/(?:[-\\w.])+(?::[0-9]+)?(?:\\/(?:[\\w/_.])*(?:\\?(?:[\\w&=%.])*)?(?:#(?:[\\w.])*)?)?$/;\n\nexport class AssertUrl extends Validation {\n public getConstraint(): AssertType {\n return Assert(`1 <= string <= ${URL_MAX_LENGTH}`);\n }\n\n public getErrorMessage(): string | null {\n return `URL must be between 1 and ${URL_MAX_LENGTH} characters and follow a valid URL format (e.g., https://example.com, http://sub.domain.co.uk/path)`;\n }\n\n public override validate(data: unknown, constraint?: AssertType): ValidationResultType {\n const basicValidation = super.validate(data, constraint);\n if (!basicValidation.isValid) {\n return basicValidation;\n }\n\n const url = data as string;\n\n // Reject specific non-http/https protocols first\n if (url.match(/^(ftp|file|mailto|telnet|ssh|gopher):/i)) {\n return {\n isValid: false,\n message: this.getErrorMessage() || \"Invalid URL format\",\n };\n }\n\n // Reject malformed protocols\n if (url.includes(\"://\") && !url.match(/^https?:\\/\\//i)) {\n return {\n isValid: false,\n message: this.getErrorMessage() || \"Invalid URL format\",\n };\n }\n\n // Check for whitespace at start or end\n if (url.trim() !== url) {\n return {\n isValid: false,\n message: this.getErrorMessage() || \"Invalid URL format\",\n };\n }\n\n // Check for invalid domain patterns\n if (url.includes(\"..\") || url.startsWith(\".\") || url.includes(\"/.\") || url.endsWith(\".\")) {\n return {\n isValid: false,\n message: this.getErrorMessage() || \"Invalid URL format\",\n };\n }\n\n if (!URL_REGEX.test(url)) {\n return {\n isValid: false,\n message: this.getErrorMessage() || \"Invalid URL format\",\n };\n }\n\n return {\n isValid: true,\n };\n }\n\n public validateStrict(data: unknown): ValidationResultType {\n const basicValidation = super.validate(data);\n if (!basicValidation.isValid) {\n return basicValidation;\n }\n\n const url = data as string;\n\n if (!STRICT_URL_REGEX.test(url)) {\n return {\n isValid: false,\n message: \"URL must include protocol (http:// or https://) and follow strict URL format\",\n };\n }\n\n return {\n isValid: true,\n };\n }\n}\n",
|
|
19
19
|
"import type { AssertType, ValidationResultType } from \"../types\";\nimport { Assert } from \"../utils\";\nimport { Validation } from \"../Validation\";\n\nconst YOUTUBE_URL_PATTERNS = [\n /^https?:\\/\\/(www\\.)?youtube\\.com\\/watch\\?v=[A-Za-z0-9_-]+$/,\n /^https?:\\/\\/youtu\\.be\\/[A-Za-z0-9_-]+$/,\n];\n\nexport class AssertYoutubeUrl extends Validation {\n public getConstraint(): AssertType {\n return Assert(\"string\");\n }\n\n public getErrorMessage(): string | null {\n return \"Must be a valid YouTube URL (e.g., https://youtube.com/watch?v=dQw4w9WgXcQ or https://youtu.be/dQw4w9WgXcQ)\";\n }\n\n public override validate(data: unknown, constraint?: AssertType): ValidationResultType {\n const basicValidation = super.validate(data, constraint);\n if (!basicValidation.isValid) {\n return basicValidation;\n }\n\n const url = data as string;\n const isValidYouTubeUrl = YOUTUBE_URL_PATTERNS.some((pattern) => pattern.test(url));\n\n if (!isValidYouTubeUrl) {\n return {\n isValid: false,\n message: this.getErrorMessage() || \"Invalid YouTube URL\",\n };\n }\n\n return {\n isValid: true,\n };\n }\n}\n"
|
|
20
20
|
],
|
|
21
|
-
"mappings": "
|
|
22
|
-
"debugId": "
|
|
21
|
+
"mappings": ";;;;;;AAAA;AAKA,IAAM,eAAe,OAAO,OAAO,WAAW;AAAA;AAEvC,MAAM,qBAAqB,WAAW;AAAA,EACpC,aAAa,GAAe;AAAA,IACjC,OAAO,OAAO,IAAI,aAAa,KAAK,OAAO,IAA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AAM,UAAU;AAAA,IACvD,IAAI,CAAC,gBAAgB,SAAS;AAAA,MAC5B,OAAO;AAAA,IACT;AAAA,IAEA,MAAM,MAAM;AAAA,IACZ,MAAM,oBAAoB,qBAAqB,KAAK,CAAC,YAAY,QAAQ,KAAK,GAAG,CAAC;AAAA,IAElF,IAAI,CAAC,mBAAmB;AAAA,MACtB,OAAO;AAAA,QACL,SAAS;AAAA,QACT,SAAS,KAAK,gBAAgB,KAAK;AAAA,MACrC;AAAA,IACF;AAAA,IAEA,OAAO;AAAA,MACL,SAAS;AAAA,IACX;AAAA;AAEJ;",
|
|
22
|
+
"debugId": "CD2ED216799B256F64756E2164756E21",
|
|
23
23
|
"names": []
|
|
24
24
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
Assert,
|
|
3
|
+
Validation,
|
|
4
|
+
jsonSchemaToTypeString
|
|
5
|
+
} from "./shared/chunk-0m070e63.js";
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
// src/index.ts
|
|
8
|
+
export * from "arktype";
|
|
9
|
+
export {
|
|
10
|
+
jsonSchemaToTypeString,
|
|
11
|
+
Validation,
|
|
12
|
+
Assert
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//# debugId=29C43C3BDDF019F664756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"export * from \"arktype\";\nexport * from \"./types\";\nexport { Assert, jsonSchemaToTypeString } from \"./utils\";\nexport { Validation } from \"./Validation\";\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;AAAA;",
|
|
8
|
+
"debugId": "29C43C3BDDF019F664756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// src/utils.ts
|
|
2
|
+
import * as A from "arktype";
|
|
3
|
+
var Assert = A.type;
|
|
4
|
+
var jsonSchemaToTypeString = (schema) => {
|
|
5
|
+
if (!schema || typeof schema !== "object")
|
|
6
|
+
return "unknown";
|
|
7
|
+
const schemaObj = schema;
|
|
8
|
+
if (schemaObj.type) {
|
|
9
|
+
switch (schemaObj.type) {
|
|
10
|
+
case "string":
|
|
11
|
+
return "string";
|
|
12
|
+
case "number":
|
|
13
|
+
case "integer":
|
|
14
|
+
return "number";
|
|
15
|
+
case "boolean":
|
|
16
|
+
return "boolean";
|
|
17
|
+
case "null":
|
|
18
|
+
return "null";
|
|
19
|
+
case "array":
|
|
20
|
+
if (schemaObj.items) {
|
|
21
|
+
return `${jsonSchemaToTypeString(schemaObj.items)}[]`;
|
|
22
|
+
}
|
|
23
|
+
return "unknown[]";
|
|
24
|
+
case "object":
|
|
25
|
+
if (schemaObj.properties && typeof schemaObj.properties === "object") {
|
|
26
|
+
const props = [];
|
|
27
|
+
const required = Array.isArray(schemaObj.required) ? schemaObj.required : [];
|
|
28
|
+
for (const [key, value] of Object.entries(schemaObj.properties)) {
|
|
29
|
+
const isRequired = required.includes(key);
|
|
30
|
+
const propType = jsonSchemaToTypeString(value);
|
|
31
|
+
props.push(`${key}${isRequired ? "" : "?"}: ${propType}`);
|
|
32
|
+
}
|
|
33
|
+
return `{ ${props.join("; ")} }`;
|
|
34
|
+
}
|
|
35
|
+
return "Record<string, unknown>";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (schemaObj.anyOf || schemaObj.oneOf) {
|
|
39
|
+
const schemas = schemaObj.anyOf || schemaObj.oneOf;
|
|
40
|
+
if (Array.isArray(schemas)) {
|
|
41
|
+
return schemas.map((s) => jsonSchemaToTypeString(s)).join(" | ");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (schemaObj.allOf && Array.isArray(schemaObj.allOf)) {
|
|
45
|
+
return schemaObj.allOf.map((s) => jsonSchemaToTypeString(s)).join(" & ");
|
|
46
|
+
}
|
|
47
|
+
return "unknown";
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/Validation.ts
|
|
51
|
+
import { type as type2 } from "arktype";
|
|
52
|
+
|
|
53
|
+
class Validation {
|
|
54
|
+
validate(data, constraint) {
|
|
55
|
+
constraint = constraint || this.getConstraint();
|
|
56
|
+
const out = constraint(data);
|
|
57
|
+
if (out instanceof type2.errors) {
|
|
58
|
+
return {
|
|
59
|
+
isValid: false,
|
|
60
|
+
message: this.getErrorMessage() || out.summary
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
isValid: true
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { Assert, jsonSchemaToTypeString, Validation };
|
|
70
|
+
|
|
71
|
+
//# debugId=205092EDC8D2884A64756E2164756E21
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"import * as A from \"arktype\";\nimport type { TypeParser } from \"arktype/internal/type.ts\";\n\n// biome-ignore lint/complexity/noBannedTypes: trust me\nexport const Assert: TypeParser<{}> = A.type;\n\n/**\n * Convert a JSON Schema type to TypeScript type string\n */\nexport const jsonSchemaToTypeString = (schema: unknown): string => {\n if (!schema || typeof schema !== \"object\") return \"unknown\";\n\n const schemaObj = schema as Record<string, unknown>;\n\n // Handle type property\n if (schemaObj.type) {\n switch (schemaObj.type) {\n case \"string\":\n return \"string\";\n case \"number\":\n case \"integer\":\n return \"number\";\n case \"boolean\":\n return \"boolean\";\n case \"null\":\n return \"null\";\n case \"array\":\n if (schemaObj.items) {\n return `${jsonSchemaToTypeString(schemaObj.items)}[]`;\n }\n return \"unknown[]\";\n case \"object\":\n if (schemaObj.properties && typeof schemaObj.properties === \"object\") {\n const props: string[] = [];\n const required = Array.isArray(schemaObj.required) ? schemaObj.required : [];\n\n for (const [key, value] of Object.entries(schemaObj.properties)) {\n const isRequired = required.includes(key);\n const propType = jsonSchemaToTypeString(value);\n props.push(`${key}${isRequired ? \"\" : \"?\"}: ${propType}`);\n }\n\n return `{ ${props.join(\"; \")} }`;\n }\n return \"Record<string, unknown>\";\n }\n }\n\n // Handle anyOf/oneOf (union types)\n if (schemaObj.anyOf || schemaObj.oneOf) {\n const schemas = schemaObj.anyOf || schemaObj.oneOf;\n if (Array.isArray(schemas)) {\n return schemas.map((s: unknown) => jsonSchemaToTypeString(s)).join(\" | \");\n }\n }\n\n // Handle allOf (intersection types)\n if (schemaObj.allOf && Array.isArray(schemaObj.allOf)) {\n return schemaObj.allOf.map((s: unknown) => jsonSchemaToTypeString(s)).join(\" & \");\n }\n\n return \"unknown\";\n};\n",
|
|
6
6
|
"import { type } from \"arktype\";\nimport type { AssertType, IAssert, ValidationResultType } from \"./types\";\n\nexport abstract class Validation implements IAssert {\n public abstract getConstraint(): AssertType;\n public abstract getErrorMessage(): string | null;\n\n public validate(data: unknown, constraint?: AssertType): ValidationResultType {\n constraint = constraint || this.getConstraint();\n\n const out = constraint(data);\n\n if (out instanceof type.errors) {\n return {\n isValid: false,\n message: this.getErrorMessage() || out.summary,\n };\n }\n\n return {\n isValid: true,\n };\n }\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": "AAAA,
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": ";AAAA;AAIO,IAAM,SAA2B;AAKjC,IAAM,yBAAyB,CAAC,WAA4B;AAAA,EACjE,IAAI,CAAC,UAAU,OAAO,WAAW;AAAA,IAAU,OAAO;AAAA,EAElD,MAAM,YAAY;AAAA,EAGlB,IAAI,UAAU,MAAM;AAAA,IAClB,QAAQ,UAAU;AAAA,WACX;AAAA,QACH,OAAO;AAAA,WACJ;AAAA,WACA;AAAA,QACH,OAAO;AAAA,WACJ;AAAA,QACH,OAAO;AAAA,WACJ;AAAA,QACH,OAAO;AAAA,WACJ;AAAA,QACH,IAAI,UAAU,OAAO;AAAA,UACnB,OAAO,GAAG,uBAAuB,UAAU,KAAK;AAAA,QAClD;AAAA,QACA,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,SAAS;AAAA,IACX;AAAA;AAEJ;",
|
|
9
|
+
"debugId": "205092EDC8D2884A64756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ooneex/validation",
|
|
3
3
|
"description": "Type-safe validation framework powered by ArkType with built-in constraints and JSON schema support",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.14",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -34,9 +34,10 @@
|
|
|
34
34
|
"npm:publish": "bun publish --tolerate-republish --access public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@ooneex/app-env": "0.0.
|
|
38
|
-
"@ooneex/currencies": "0.0.
|
|
39
|
-
"@ooneex/translation": "0.0.
|
|
37
|
+
"@ooneex/app-env": "0.0.13",
|
|
38
|
+
"@ooneex/currencies": "0.0.13",
|
|
39
|
+
"@ooneex/translation": "0.0.13",
|
|
40
|
+
"arktype": "^2.1.29"
|
|
40
41
|
},
|
|
41
42
|
"keywords": [
|
|
42
43
|
"arktype",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import*as V from"arktype";var p=V.type,l=(i)=>{if(!i||typeof i!=="object")return"unknown";let t=i;if(t.type)switch(t.type){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";case"array":if(t.items)return`${l(t.items)}[]`;return"unknown[]";case"object":if(t.properties&&typeof t.properties==="object"){let r=[],u=Array.isArray(t.required)?t.required:[];for(let[A,f]of Object.entries(t.properties)){let g=u.includes(A),d=l(f);r.push(`${A}${g?"":"?"}: ${d}`)}return`{ ${r.join("; ")} }`}return"Record<string, unknown>"}if(t.anyOf||t.oneOf){let r=t.anyOf||t.oneOf;if(Array.isArray(r))return r.map((u)=>l(u)).join(" | ")}if(t.allOf&&Array.isArray(t.allOf))return t.allOf.map((r)=>l(r)).join(" & ");return"unknown"};import{type as n}from"arktype";class o{validate(i,t){t=t||this.getConstraint();let r=t(i);if(r instanceof n.errors)return{isValid:!1,message:this.getErrorMessage()||r.summary};return{isValid:!0}}}
|
|
2
|
-
export{p as a,l as b,o as c};
|
|
3
|
-
|
|
4
|
-
//# debugId=74A74E5B17B5E66964756E2164756E21
|