@travetto/schema 3.3.2 → 3.3.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.
package/README.md CHANGED
@@ -84,6 +84,7 @@ This schema provides a powerful base for data binding and validation at runtime.
84
84
  * [@Writeonly](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L52) defines a that field should not be exported in serialization, but that it can be bound to
85
85
  * [@Secret](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L64) marks a field as being sensitive. This is used by certain logging activities to ensure sensitive information is not logged out.
86
86
  * [@Specifier](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L206) attributes additional specifiers to a field, allowing for more specification beyond just the field's type.
87
+ * [@SubTypeField](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L212) allows for promoting a given field as the owner of the sub type discriminator (defaults to `type`).
87
88
  Additionally, schemas can be nested to form more complex data structures that are able to bound and validated.
88
89
 
89
90
  Just like the class, all fields can be defined with
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/schema",
3
- "version": "3.3.2",
3
+ "version": "3.3.4",
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": "^3.3.2"
30
+ "@travetto/registry": "^3.3.3"
31
31
  },
32
32
  "peerDependencies": {
33
- "@travetto/transformer": "^3.3.1"
33
+ "@travetto/transformer": "^3.3.2"
34
34
  },
35
35
  "peerDependenciesMeta": {
36
36
  "@travetto/transformer": {
@@ -203,4 +203,14 @@ export function Ignore(): PropertyDecorator {
203
203
  * @param specifiers The specifiers for a field
204
204
  * @augments `@travetto/schema:Field`
205
205
  */
206
- export function Specifier(...specifiers: string[]): PropType<unknown> { return prop({ specifiers }); }
206
+ export function Specifier(...specifiers: string[]): PropType<unknown> { return prop({ specifiers }); }
207
+
208
+ /**
209
+ * Sets the subtype field via a property decorator
210
+ * @augments `@travetto/schema:Field`
211
+ */
212
+ export function SubTypeField(): ((t: ClassInstance, k: string) => void) {
213
+ return (t: ClassInstance, k: string): void => {
214
+ SchemaRegistry.register(t.constructor, { subTypeField: k });
215
+ };
216
+ }