aboutsummaryrefslogtreecommitdiffstats
path: root/packages/assert/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-02-21 03:39:36 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-02-21 03:39:36 +0800
commit7b67afae06c93290e6d8c4a4f0de2435f31ae714 (patch)
treea097adbdae48b52ccb2cc1a7445ef3e622fd0c1b /packages/assert/src
parentfe9e319a6136d4be4fa94287ad709a127c548750 (diff)
downloaddexon-sol-tools-7b67afae06c93290e6d8c4a4f0de2435f31ae714.tar
dexon-sol-tools-7b67afae06c93290e6d8c4a4f0de2435f31ae714.tar.gz
dexon-sol-tools-7b67afae06c93290e6d8c4a4f0de2435f31ae714.tar.bz2
dexon-sol-tools-7b67afae06c93290e6d8c4a4f0de2435f31ae714.tar.lz
dexon-sol-tools-7b67afae06c93290e6d8c4a4f0de2435f31ae714.tar.xz
dexon-sol-tools-7b67afae06c93290e6d8c4a4f0de2435f31ae714.tar.zst
dexon-sol-tools-7b67afae06c93290e6d8c4a4f0de2435f31ae714.zip
Change assert.doesConformToShema interface
Diffstat (limited to 'packages/assert/src')
-rw-r--r--packages/assert/src/index.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/packages/assert/src/index.ts b/packages/assert/src/index.ts
index 383cc2c42..71f2cbeb2 100644
--- a/packages/assert/src/index.ts
+++ b/packages/assert/src/index.ts
@@ -4,10 +4,8 @@ import * as _ from 'lodash';
import * as validUrl from 'valid-url';
const HEX_REGEX = /^0x[0-9A-F]*$/i;
-const schemaValidator = new SchemaValidator();
export const assert = {
- schemaValidator,
isBigNumber(variableName: string, value: BigNumber): void {
const isBigNumber = _.isObject(value) && (value as any).isBigNumber;
this.assert(isBigNumber, this.typeAssertionMessage(variableName, 'BigNumber', value));
@@ -68,8 +66,10 @@ export const assert = {
const isWeb3Provider = _.isFunction(value.send) || _.isFunction(value.sendAsync);
this.assert(isWeb3Provider, this.typeAssertionMessage(variableName, 'Web3.Provider', value));
},
- doesConformToSchema(variableName: string, value: any, schema: Schema): void {
- const validationResult = this.schemaValidator.validate(value, schema);
+ doesConformToSchema(variableName: string, value: any, schema: Schema, subSchemas?: Schema[]): void {
+ const schemaValidator = new SchemaValidator();
+ _.map(subSchemas, schemaValidator.addSchema.bind(schemaValidator));
+ const validationResult = schemaValidator.validate(value, schema);
const hasValidationErrors = validationResult.errors.length > 0;
const msg = `Expected ${variableName} to conform to schema ${schema.id}
Encountered: ${JSON.stringify(value, null, '\t')}