aboutsummaryrefslogtreecommitdiffstats
path: root/packages/assert
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-02-09 01:01:53 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-02-15 03:22:36 +0800
commitf3e6ef0fa96e2252e41b7ed6f2c3e88a1560153e (patch)
tree0208e1e119e1a6976e8e2332eaca9681b4ae20ed /packages/assert
parent18e1c2dea5d3c5387db6f616cd0ebbfe89dc308b (diff)
downloaddexon-sol-tools-f3e6ef0fa96e2252e41b7ed6f2c3e88a1560153e.tar
dexon-sol-tools-f3e6ef0fa96e2252e41b7ed6f2c3e88a1560153e.tar.gz
dexon-sol-tools-f3e6ef0fa96e2252e41b7ed6f2c3e88a1560153e.tar.bz2
dexon-sol-tools-f3e6ef0fa96e2252e41b7ed6f2c3e88a1560153e.tar.lz
dexon-sol-tools-f3e6ef0fa96e2252e41b7ed6f2c3e88a1560153e.tar.xz
dexon-sol-tools-f3e6ef0fa96e2252e41b7ed6f2c3e88a1560153e.tar.zst
dexon-sol-tools-f3e6ef0fa96e2252e41b7ed6f2c3e88a1560153e.zip
Better validate ZeroExConfig on public networks
Diffstat (limited to 'packages/assert')
-rw-r--r--packages/assert/src/index.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/packages/assert/src/index.ts b/packages/assert/src/index.ts
index 7ad574ec7..38b330a46 100644
--- a/packages/assert/src/index.ts
+++ b/packages/assert/src/index.ts
@@ -4,8 +4,10 @@ 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));
@@ -67,8 +69,7 @@ export const assert = {
this.assert(isWeb3Provider, this.typeAssertionMessage(variableName, 'Web3.Provider', value));
},
doesConformToSchema(variableName: string, value: any, schema: Schema): void {
- const schemaValidator = new SchemaValidator();
- const validationResult = schemaValidator.validate(value, schema);
+ const validationResult = assert.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')}