@sprucelabs/schema 31.0.2 → 31.0.4

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.
@@ -217,19 +217,20 @@ class SchemaField extends AbstractField {
217
217
  });
218
218
  }
219
219
  else {
220
- const matchSchema = schemas.find((schema) => schema.id === id && schema.version === version);
221
- if (!matchSchema) {
220
+ const matches = schemas.filter((schema) => schema.id === id &&
221
+ (!version || schema.version === version));
222
+ if (matches.length !== 1) {
222
223
  errors.push({
223
224
  name: this.name,
224
225
  label: this.label,
225
226
  code: 'INVALID_PARAMETER',
226
227
  friendlyMessage: `Could not find a schema by id '${id}'${version
227
228
  ? ` and version '${version}'`
228
- : ' with no version'}.`,
229
+ : ' with no version. Try adding a version to disambiguate.'}.`,
229
230
  });
230
231
  }
231
232
  else {
232
- instance = this.Schema(matchSchema, values);
233
+ instance = this.Schema(matches[0], values);
233
234
  }
234
235
  }
235
236
  }
@@ -221,19 +221,20 @@ class SchemaField extends AbstractField_1.default {
221
221
  });
222
222
  }
223
223
  else {
224
- const matchSchema = schemas.find((schema) => schema.id === id && schema.version === version);
225
- if (!matchSchema) {
224
+ const matches = schemas.filter((schema) => schema.id === id &&
225
+ (!version || schema.version === version));
226
+ if (matches.length !== 1) {
226
227
  errors.push({
227
228
  name: this.name,
228
229
  label: this.label,
229
230
  code: 'INVALID_PARAMETER',
230
231
  friendlyMessage: `Could not find a schema by id '${id}'${version
231
232
  ? ` and version '${version}'`
232
- : ' with no version'}.`,
233
+ : ' with no version. Try adding a version to disambiguate.'}.`,
233
234
  });
234
235
  }
235
236
  else {
236
- instance = this.Schema(matchSchema, values);
237
+ instance = this.Schema(matches[0], values);
237
238
  }
238
239
  }
239
240
  }
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "!build/__tests__",
9
9
  "esm"
10
10
  ],
11
- "version": "31.0.2",
11
+ "version": "31.0.4",
12
12
  "main": "./build/index.js",
13
13
  "types": "./build/index.d.ts",
14
14
  "module": "./build/esm/index.js",
@@ -58,15 +58,15 @@
58
58
  "build.copy-files": "mkdir -p build && rsync -avzq --exclude='*.ts' ./src/ ./build/"
59
59
  },
60
60
  "dependencies": {
61
- "@sprucelabs/error": "^6.0.556",
62
- "@sprucelabs/test-utils": "^5.1.529",
61
+ "@sprucelabs/error": "^6.0.557",
62
+ "@sprucelabs/test-utils": "^5.1.531",
63
63
  "email-validator": "^2.0.4",
64
64
  "just-safe-get": "^4.2.0",
65
65
  "just-safe-set": "^4.2.1"
66
66
  },
67
67
  "devDependencies": {
68
- "@sprucelabs/esm-postbuild": "^6.0.533",
69
- "@sprucelabs/jest-json-reporter": "^8.0.558",
68
+ "@sprucelabs/esm-postbuild": "^6.0.534",
69
+ "@sprucelabs/jest-json-reporter": "^8.0.559",
70
70
  "@sprucelabs/resolve-path-aliases": "^2.0.523",
71
71
  "@sprucelabs/semantic-release": "^5.0.2",
72
72
  "@sprucelabs/test": "^9.0.64",