@travetto/schema
Advanced tools
Comparing version 3.0.0-rc.10 to 3.0.0-rc.11
{ | ||
"name": "@travetto/schema", | ||
"version": "3.0.0-rc.10", | ||
"version": "3.0.0-rc.11", | ||
"description": "Data type registry for runtime validation, reflection and binding.", | ||
@@ -30,6 +30,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@travetto/registry": "^3.0.0-rc.10" | ||
"@travetto/registry": "^3.0.0-rc.11" | ||
}, | ||
"peerDependencies": { | ||
"@travetto/transformer": "^3.0.0-rc.9" | ||
"@travetto/transformer": "^3.0.0-rc.10" | ||
}, | ||
@@ -36,0 +36,0 @@ "peerDependenciesMeta": { |
@@ -143,3 +143,3 @@ <!-- This file was generated by @travetto/doc and should not be modified directly --> | ||
```bash | ||
$ trv main support/main.person-output.ts | ||
$ trv main doc/person-output.ts | ||
@@ -151,3 +151,2 @@ Person { | ||
} | ||
[s[r[u | ||
``` | ||
@@ -206,5 +205,23 @@ | ||
```bash | ||
$ trv main support/main.person-invalid-output.ts | ||
$ trv main doc/person-invalid-output.ts | ||
[s[r[u | ||
Validation Failed { | ||
"message": "Validation errors have occurred", | ||
"category": "data", | ||
"type": "ValidationResultError", | ||
"at": "2029-03-14T04:00:00.618Z", | ||
"errors": [ | ||
{ | ||
"kind": "type", | ||
"message": "age is not a valid number", | ||
"path": "age", | ||
"type": "number" | ||
}, | ||
{ | ||
"kind": "required", | ||
"message": "address.street2 is required", | ||
"path": "address.street2" | ||
} | ||
] | ||
} | ||
``` | ||
@@ -330,5 +347,18 @@ | ||
```bash | ||
$ trv main support/main.custom-type-output.ts | ||
$ trv main doc/custom-type-output.ts | ||
[s[r[u | ||
Validation Failed { | ||
"message": "Validation errors have occurred", | ||
"category": "data", | ||
"type": "ValidationResultError", | ||
"at": "2029-03-14T04:00:00.837Z", | ||
"errors": [ | ||
{ | ||
"kind": "type", | ||
"message": "point is not a valid PointImpl", | ||
"path": "point", | ||
"type": "PointImpl" | ||
} | ||
] | ||
} | ||
``` |
@@ -309,2 +309,13 @@ import { Class, ConcreteClass, TypedObject, ObjectUtil, DataUtil } from '@travetto/base'; | ||
} | ||
/** | ||
* Coerce method parameters when possible | ||
* @param cls | ||
* @param method | ||
* @param params | ||
* @returns | ||
*/ | ||
static coerceMethodParams<T>(cls: Class<T>, method: string, params: unknown[], applyDefaults = false): unknown[] { | ||
return this.coerceFields(SchemaRegistry.getMethodSchema(cls, method), params, applyDefaults); | ||
} | ||
} |
@@ -6,3 +6,2 @@ import { Class, AppError, ObjectUtil, ClassInstance, ConcreteClass } from '@travetto/base'; | ||
import { SchemaChangeListener } from './changes'; | ||
import { BindUtil } from '../bind-util'; | ||
import { AllViewⲐ } from '../internal/types'; | ||
@@ -249,13 +248,2 @@ | ||
/** | ||
* Coerce method parameters when possible | ||
* @param cls | ||
* @param method | ||
* @param params | ||
* @returns | ||
*/ | ||
coerceMethodParams<T>(cls: Class<T>, method: string, params: unknown[], applyDefaults = false): unknown[] { | ||
return BindUtil.coerceFields(this.getMethodSchema(cls, method), params, applyDefaults); | ||
} | ||
/** | ||
* Register a view | ||
@@ -262,0 +250,0 @@ * @param target The target class |
87000
361
1954