@travetto/schema 5.0.0 → 5.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/schema",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "Data type registry for runtime validation, reflection and binding.",
5
5
  "keywords": [
6
6
  "schema",
@@ -27,10 +27,10 @@
27
27
  "directory": "module/schema"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/registry": "^5.0.0"
30
+ "@travetto/registry": "^5.0.1"
31
31
  },
32
32
  "peerDependencies": {
33
- "@travetto/transformer": "^5.0.0"
33
+ "@travetto/transformer": "^5.0.1"
34
34
  },
35
35
  "peerDependenciesMeta": {
36
36
  "@travetto/transformer": {
@@ -458,6 +458,22 @@ class $SchemaRegistry extends MetadataRegistry<ClassConfig, FieldConfig> {
458
458
  });
459
459
  }
460
460
  }
461
+
462
+ /**
463
+ * Visit fields recursively
464
+ */
465
+ visitFields<T>(cls: Class<T>, onField: (field: FieldConfig, path: FieldConfig[]) => void, _path: FieldConfig[] = [], root = cls): void {
466
+ const fields = this.has(cls) ?
467
+ Object.values(this.getViewSchema(cls).schema) :
468
+ [];
469
+ for (const field of fields) {
470
+ if (this.has(field.type)) {
471
+ this.visitFields(field.type, onField, [..._path, field], root);
472
+ } else {
473
+ onField(field, _path);
474
+ }
475
+ }
476
+ }
461
477
  }
462
478
 
463
479
  export const SchemaRegistry = new $SchemaRegistry();