@forklaunch/validator 0.9.4 → 0.9.5
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/lib/src/typebox/index.js +37 -5
- package/lib/src/typebox/index.mjs +37 -5
- package/lib/src/zod/index.js +1 -1
- package/lib/src/zod/index.mjs +1 -1
- package/package.json +2 -2
package/lib/src/typebox/index.js
CHANGED
|
@@ -92,7 +92,7 @@ var TypeboxSchemaValidator = class {
|
|
|
92
92
|
title: "UUID"
|
|
93
93
|
});
|
|
94
94
|
email = import_typebox.Type.String({
|
|
95
|
-
pattern:
|
|
95
|
+
pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
|
96
96
|
errorType: "email",
|
|
97
97
|
example: "a@b.com",
|
|
98
98
|
title: "Email"
|
|
@@ -263,7 +263,9 @@ var TypeboxSchemaValidator = class {
|
|
|
263
263
|
example: "a raw buffer or file stream",
|
|
264
264
|
title: "File"
|
|
265
265
|
})
|
|
266
|
-
).Decode((value) =>
|
|
266
|
+
).Decode((value) => {
|
|
267
|
+
return new import_common.InMemoryBlob(value);
|
|
268
|
+
}).Encode((value) => value.content);
|
|
267
269
|
type = () => this.any;
|
|
268
270
|
/**
|
|
269
271
|
* Extracts the error type of a schema for error messages.
|
|
@@ -450,10 +452,40 @@ var TypeboxSchemaValidator = class {
|
|
|
450
452
|
}
|
|
451
453
|
} else {
|
|
452
454
|
const schemified = this.schemify(schema);
|
|
453
|
-
if (
|
|
454
|
-
|
|
455
|
+
if (schemified[import_typebox.Kind] === "Unsafe") {
|
|
456
|
+
try {
|
|
457
|
+
if (value instanceof Buffer) {
|
|
458
|
+
conversion = new import_common.InMemoryBlob(value);
|
|
459
|
+
} else {
|
|
460
|
+
errors = [
|
|
461
|
+
{
|
|
462
|
+
type: import_errors.ValueErrorType.String,
|
|
463
|
+
schema: schemified,
|
|
464
|
+
path: "",
|
|
465
|
+
message: `Invalid file type: expected Buffer or string, got ${typeof value}`,
|
|
466
|
+
value,
|
|
467
|
+
errors: []
|
|
468
|
+
}
|
|
469
|
+
];
|
|
470
|
+
}
|
|
471
|
+
} catch (err) {
|
|
472
|
+
errors = [
|
|
473
|
+
{
|
|
474
|
+
type: import_errors.ValueErrorType.String,
|
|
475
|
+
schema: schemified,
|
|
476
|
+
path: "",
|
|
477
|
+
message: err instanceof Error ? err.message : "Invalid file type",
|
|
478
|
+
value,
|
|
479
|
+
errors: []
|
|
480
|
+
}
|
|
481
|
+
];
|
|
482
|
+
}
|
|
455
483
|
} else {
|
|
456
|
-
|
|
484
|
+
if (import_value.Value.Check(schemified, value)) {
|
|
485
|
+
conversion = import_value.Value.Decode(schemified, value);
|
|
486
|
+
} else {
|
|
487
|
+
errors = Array.from(import_value.Value.Errors(schemified, value));
|
|
488
|
+
}
|
|
457
489
|
}
|
|
458
490
|
}
|
|
459
491
|
return errors != null && errors.length === 0 ? {
|
|
@@ -43,7 +43,7 @@ var TypeboxSchemaValidator = class {
|
|
|
43
43
|
title: "UUID"
|
|
44
44
|
});
|
|
45
45
|
email = Type.String({
|
|
46
|
-
pattern:
|
|
46
|
+
pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
|
47
47
|
errorType: "email",
|
|
48
48
|
example: "a@b.com",
|
|
49
49
|
title: "Email"
|
|
@@ -214,7 +214,9 @@ var TypeboxSchemaValidator = class {
|
|
|
214
214
|
example: "a raw buffer or file stream",
|
|
215
215
|
title: "File"
|
|
216
216
|
})
|
|
217
|
-
).Decode((value) =>
|
|
217
|
+
).Decode((value) => {
|
|
218
|
+
return new InMemoryBlob(value);
|
|
219
|
+
}).Encode((value) => value.content);
|
|
218
220
|
type = () => this.any;
|
|
219
221
|
/**
|
|
220
222
|
* Extracts the error type of a schema for error messages.
|
|
@@ -401,10 +403,40 @@ var TypeboxSchemaValidator = class {
|
|
|
401
403
|
}
|
|
402
404
|
} else {
|
|
403
405
|
const schemified = this.schemify(schema);
|
|
404
|
-
if (
|
|
405
|
-
|
|
406
|
+
if (schemified[Kind] === "Unsafe") {
|
|
407
|
+
try {
|
|
408
|
+
if (value instanceof Buffer) {
|
|
409
|
+
conversion = new InMemoryBlob(value);
|
|
410
|
+
} else {
|
|
411
|
+
errors = [
|
|
412
|
+
{
|
|
413
|
+
type: ValueErrorType.String,
|
|
414
|
+
schema: schemified,
|
|
415
|
+
path: "",
|
|
416
|
+
message: `Invalid file type: expected Buffer or string, got ${typeof value}`,
|
|
417
|
+
value,
|
|
418
|
+
errors: []
|
|
419
|
+
}
|
|
420
|
+
];
|
|
421
|
+
}
|
|
422
|
+
} catch (err) {
|
|
423
|
+
errors = [
|
|
424
|
+
{
|
|
425
|
+
type: ValueErrorType.String,
|
|
426
|
+
schema: schemified,
|
|
427
|
+
path: "",
|
|
428
|
+
message: err instanceof Error ? err.message : "Invalid file type",
|
|
429
|
+
value,
|
|
430
|
+
errors: []
|
|
431
|
+
}
|
|
432
|
+
];
|
|
433
|
+
}
|
|
406
434
|
} else {
|
|
407
|
-
|
|
435
|
+
if (Value.Check(schemified, value)) {
|
|
436
|
+
conversion = Value.Decode(schemified, value);
|
|
437
|
+
} else {
|
|
438
|
+
errors = Array.from(Value.Errors(schemified, value));
|
|
439
|
+
}
|
|
408
440
|
}
|
|
409
441
|
}
|
|
410
442
|
return errors != null && errors.length === 0 ? {
|
package/lib/src/zod/index.js
CHANGED
|
@@ -658,7 +658,7 @@ var ZodSchemaValidator = class {
|
|
|
658
658
|
email = import_v32.z.string().email().openapi({
|
|
659
659
|
title: "Email",
|
|
660
660
|
format: "email",
|
|
661
|
-
pattern:
|
|
661
|
+
pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
|
662
662
|
example: "a@b.com"
|
|
663
663
|
});
|
|
664
664
|
uri = import_v32.z.string().url().openapi({
|
package/lib/src/zod/index.mjs
CHANGED
|
@@ -602,7 +602,7 @@ var ZodSchemaValidator = class {
|
|
|
602
602
|
email = z2.string().email().openapi({
|
|
603
603
|
title: "Email",
|
|
604
604
|
format: "email",
|
|
605
|
-
pattern:
|
|
605
|
+
pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
|
|
606
606
|
example: "a@b.com"
|
|
607
607
|
});
|
|
608
608
|
uri = z2.string().url().openapi({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/validator",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "Schema validator for ForkLaunch components.",
|
|
5
5
|
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@sinclair/typebox": "^0.34.40",
|
|
62
62
|
"ts-deepmerge": "^7.0.3",
|
|
63
63
|
"zod": "^4.1.1",
|
|
64
|
-
"@forklaunch/common": "0.5.
|
|
64
|
+
"@forklaunch/common": "0.5.4"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@eslint/js": "^9.34.0",
|