@forklaunch/validator 0.9.4 → 0.9.6

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.
@@ -92,7 +92,7 @@ var TypeboxSchemaValidator = class {
92
92
  title: "UUID"
93
93
  });
94
94
  email = import_typebox.Type.String({
95
- pattern: `(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x5b-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)])`,
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) => new import_common.InMemoryBlob(value)).Encode((value) => value.content);
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 (import_value.Value.Check(schemified, value)) {
454
- conversion = import_value.Value.Decode(schemified, value);
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
- errors = Array.from(import_value.Value.Errors(schemified, value));
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: `(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x5b-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)])`,
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) => new InMemoryBlob(value)).Encode((value) => value.content);
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 (Value.Check(schemified, value)) {
405
- conversion = Value.Decode(schemified, value);
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
- errors = Array.from(Value.Errors(schemified, value));
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 ? {
@@ -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: `(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x5b-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)])`,
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({
@@ -602,7 +602,7 @@ var ZodSchemaValidator = class {
602
602
  email = z2.string().email().openapi({
603
603
  title: "Email",
604
604
  format: "email",
605
- pattern: `(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x5b-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)])`,
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.4",
3
+ "version": "0.9.6",
4
4
  "description": "Schema validator for ForkLaunch components.",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {
@@ -61,13 +61,13 @@
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.3"
64
+ "@forklaunch/common": "0.5.5"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@eslint/js": "^9.34.0",
68
68
  "@types/jest": "^30.0.0",
69
69
  "@types/node": "^24.3.0",
70
- "@typescript/native-preview": "7.0.0-dev.20250824.1",
70
+ "@typescript/native-preview": "7.0.0-dev.20250825.1",
71
71
  "@vitest/coverage-v8": "^3.2.4",
72
72
  "eslint-config-prettier": "^10.1.8",
73
73
  "eslint-plugin-prettier": "^5.5.4",
@@ -77,7 +77,7 @@
77
77
  "ts-jest": "^29.4.1",
78
78
  "ts-node": "^10.9.2",
79
79
  "tsup": "^8.5.0",
80
- "typedoc": "^0.28.10",
80
+ "typedoc": "^0.28.11",
81
81
  "typescript-eslint": "^8.40.0"
82
82
  },
83
83
  "scripts": {