@vertz/schema 0.2.1 → 0.2.3

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 (2) hide show
  1. package/dist/index.js +13 -0
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1144,6 +1144,13 @@ class CoercedStringSchema extends StringSchema {
1144
1144
 
1145
1145
  class CoercedNumberSchema extends NumberSchema {
1146
1146
  _parse(value, ctx) {
1147
+ if (typeof value === "string" && value.trim() === "") {
1148
+ ctx.addIssue({
1149
+ code: "invalid_type" /* InvalidType */,
1150
+ message: "Expected number, received empty string"
1151
+ });
1152
+ return 0;
1153
+ }
1147
1154
  return super._parse(Number(value), ctx);
1148
1155
  }
1149
1156
  _clone() {
@@ -1807,6 +1814,8 @@ class ObjectSchema extends Schema {
1807
1814
  if (unknownKeys.length > 0) {
1808
1815
  if (this._catchall) {
1809
1816
  for (const key of unknownKeys) {
1817
+ if (key === "__proto__")
1818
+ continue;
1810
1819
  ctx.pushPath(key);
1811
1820
  result[key] = this._catchall._runPipeline(obj[key], ctx);
1812
1821
  ctx.popPath();
@@ -1818,6 +1827,8 @@ class ObjectSchema extends Schema {
1818
1827
  });
1819
1828
  } else if (this._unknownKeys === "passthrough") {
1820
1829
  for (const key of unknownKeys) {
1830
+ if (key === "__proto__")
1831
+ continue;
1821
1832
  result[key] = obj[key];
1822
1833
  }
1823
1834
  }
@@ -1950,6 +1961,8 @@ class RecordSchema extends Schema {
1950
1961
  const obj = value;
1951
1962
  const result = {};
1952
1963
  for (const key of Object.keys(obj)) {
1964
+ if (key === "__proto__")
1965
+ continue;
1953
1966
  ctx.pushPath(key);
1954
1967
  if (this._keySchema) {
1955
1968
  this._keySchema._runPipeline(key, ctx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertz/schema",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Type-safe schema definitions for Vertz",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "@vitest/coverage-v8": "^4.0.18",
39
- "bunup": "latest",
39
+ "bunup": "^0.16.31",
40
40
  "typescript": "^5.7.0",
41
41
  "vitest": "^4.0.18"
42
42
  },