aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-09 16:40:06 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-09 16:40:06 +0800
commit71be75e0ed5a7e930bcb2fe8aa06ab1ec033fdee (patch)
treefed3d7f9a6ec08262308b43aef7e08dd19db8e72 /src/utils
parentab40123768a3376bd2b36bd0d85a8e476b89dc10 (diff)
downloaddexon-sol-tools-71be75e0ed5a7e930bcb2fe8aa06ab1ec033fdee.tar
dexon-sol-tools-71be75e0ed5a7e930bcb2fe8aa06ab1ec033fdee.tar.gz
dexon-sol-tools-71be75e0ed5a7e930bcb2fe8aa06ab1ec033fdee.tar.bz2
dexon-sol-tools-71be75e0ed5a7e930bcb2fe8aa06ab1ec033fdee.tar.lz
dexon-sol-tools-71be75e0ed5a7e930bcb2fe8aa06ab1ec033fdee.tar.xz
dexon-sol-tools-71be75e0ed5a7e930bcb2fe8aa06ab1ec033fdee.tar.zst
dexon-sol-tools-71be75e0ed5a7e930bcb2fe8aa06ab1ec033fdee.zip
Convert to JSON schema compatible object by default
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/schema_validator.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/utils/schema_validator.ts b/src/utils/schema_validator.ts
index 72f6afffa..41c4696d6 100644
--- a/src/utils/schema_validator.ts
+++ b/src/utils/schema_validator.ts
@@ -11,7 +11,7 @@ export class SchemaValidator {
// sub-types (e.g BigNumber) with a simpler string representation. Since BigNumber and other
// complex types implement the `toString` method, we can stringify the object and
// then parse it. The resultant object can then be checked using jsonschema.
- public static convertToJSONSchemaCompatibleObject(obj: any): any {
+ private static convertToJSONSchemaCompatibleObject(obj: any): any {
return JSON.parse(JSON.stringify(obj));
}
constructor() {
@@ -25,7 +25,8 @@ export class SchemaValidator {
this.validator.addSchema(ecSignatureParameter, ecSignatureParameter.id);
this.validator.addSchema(orderFillOrKillRequestsSchema, orderFillOrKillRequestsSchema.id);
}
- public validate(instance: object, schema: Schema): ValidatorResult {
- return this.validator.validate(instance, schema);
+ public validate(instance: any, schema: Schema): ValidatorResult {
+ const jsonSchemaCompatibleObject = SchemaValidator.convertToJSONSchemaCompatibleObject(instance);
+ return this.validator.validate(jsonSchemaCompatibleObject, schema);
}
}