diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-05-25 07:52:35 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-05-30 01:09:09 +0800 |
commit | 9854db0a63fcf356425d307b4813e3ed65c38066 (patch) | |
tree | 4816ea41dd6e3a81678426d990a76a2f7ae81439 /packages/assert | |
parent | cc7b0f4623ef1f9590a81a0f2206241df1abeb31 (diff) | |
download | dexon-sol-tools-9854db0a63fcf356425d307b4813e3ed65c38066.tar dexon-sol-tools-9854db0a63fcf356425d307b4813e3ed65c38066.tar.gz dexon-sol-tools-9854db0a63fcf356425d307b4813e3ed65c38066.tar.bz2 dexon-sol-tools-9854db0a63fcf356425d307b4813e3ed65c38066.tar.lz dexon-sol-tools-9854db0a63fcf356425d307b4813e3ed65c38066.tar.xz dexon-sol-tools-9854db0a63fcf356425d307b4813e3ed65c38066.tar.zst dexon-sol-tools-9854db0a63fcf356425d307b4813e3ed65c38066.zip |
Throw if trying to schema-validate an undefined
Diffstat (limited to 'packages/assert')
-rw-r--r-- | packages/assert/src/index.ts | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/packages/assert/src/index.ts b/packages/assert/src/index.ts index f3b3651d5..95c7b658b 100644 --- a/packages/assert/src/index.ts +++ b/packages/assert/src/index.ts @@ -64,6 +64,9 @@ export const assert = { this.assert(isWeb3Provider, this.typeAssertionMessage(variableName, 'Provider', value)); }, doesConformToSchema(variableName: string, value: any, schema: Schema, subSchemas?: Schema[]): void { + if (_.isUndefined(value)) { + throw new Error(`${variableName} can't be undefined`); + } const schemaValidator = new SchemaValidator(); if (!_.isUndefined(subSchemas)) { _.map(subSchemas, schemaValidator.addSchema.bind(schemaValidator)); |