aboutsummaryrefslogtreecommitdiffstats
path: root/packages/assert/src/index.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-07-18 21:27:38 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-07-18 21:27:38 +0800
commitdad557164ea4ccc012243d43df013078a7c37eb6 (patch)
tree88e8477941dc0c98273fcb054086b2e89d034e19 /packages/assert/src/index.ts
parentacff177c547dee049b97e4b051fe22e1efaf992c (diff)
parentf3241ff86a0d99f4291c5a5f4eaaa5ebe1736da0 (diff)
downloaddexon-sol-tools-dad557164ea4ccc012243d43df013078a7c37eb6.tar
dexon-sol-tools-dad557164ea4ccc012243d43df013078a7c37eb6.tar.gz
dexon-sol-tools-dad557164ea4ccc012243d43df013078a7c37eb6.tar.bz2
dexon-sol-tools-dad557164ea4ccc012243d43df013078a7c37eb6.tar.lz
dexon-sol-tools-dad557164ea4ccc012243d43df013078a7c37eb6.tar.xz
dexon-sol-tools-dad557164ea4ccc012243d43df013078a7c37eb6.tar.zst
dexon-sol-tools-dad557164ea4ccc012243d43df013078a7c37eb6.zip
Merge branch 'v2-prototype' into feature/order-watcher-v2
Diffstat (limited to 'packages/assert/src/index.ts')
-rw-r--r--packages/assert/src/index.ts32
1 files changed, 16 insertions, 16 deletions
diff --git a/packages/assert/src/index.ts b/packages/assert/src/index.ts
index 8e18416c5..ccf2c9ad8 100644
--- a/packages/assert/src/index.ts
+++ b/packages/assert/src/index.ts
@@ -8,33 +8,33 @@ const HEX_REGEX = /^0x[0-9A-F]*$/i;
export const assert = {
isBigNumber(variableName: string, value: BigNumber): void {
const isBigNumber = _.isObject(value) && (value as any).isBigNumber;
- this.assert(isBigNumber, this.typeAssertionMessage(variableName, 'BigNumber', value));
+ assert.assert(isBigNumber, assert.typeAssertionMessage(variableName, 'BigNumber', value));
},
isValidBaseUnitAmount(variableName: string, value: BigNumber): void {
assert.isBigNumber(variableName, value);
const isNegative = value.lessThan(0);
- this.assert(!isNegative, `${variableName} cannot be a negative number, found value: ${value.toNumber()}`);
+ assert.assert(!isNegative, `${variableName} cannot be a negative number, found value: ${value.toNumber()}`);
const hasDecimals = value.decimalPlaces() !== 0;
- this.assert(
+ assert.assert(
!hasDecimals,
`${variableName} should be in baseUnits (no decimals), found value: ${value.toNumber()}`,
);
},
isString(variableName: string, value: string): void {
- this.assert(_.isString(value), this.typeAssertionMessage(variableName, 'string', value));
+ assert.assert(_.isString(value), assert.typeAssertionMessage(variableName, 'string', value));
},
isFunction(variableName: string, value: any): void {
- this.assert(_.isFunction(value), this.typeAssertionMessage(variableName, 'function', value));
+ assert.assert(_.isFunction(value), assert.typeAssertionMessage(variableName, 'function', value));
},
isHexString(variableName: string, value: string): void {
- this.assert(
+ assert.assert(
_.isString(value) && HEX_REGEX.test(value),
- this.typeAssertionMessage(variableName, 'HexString', value),
+ assert.typeAssertionMessage(variableName, 'HexString', value),
);
},
isETHAddressHex(variableName: string, value: string): void {
- this.assert(_.isString(value), this.typeAssertionMessage(variableName, 'string', value));
- this.assert(addressUtils.isAddress(value), this.typeAssertionMessage(variableName, 'ETHAddressHex', value));
+ assert.assert(_.isString(value), assert.typeAssertionMessage(variableName, 'string', value));
+ assert.assert(addressUtils.isAddress(value), assert.typeAssertionMessage(variableName, 'ETHAddressHex', value));
},
doesBelongToStringEnum(
variableName: string,
@@ -51,17 +51,17 @@ export const assert = {
);
},
hasAtMostOneUniqueValue(value: any[], errMsg: string): void {
- this.assert(_.uniq(value).length <= 1, errMsg);
+ assert.assert(_.uniq(value).length <= 1, errMsg);
},
isNumber(variableName: string, value: number): void {
- this.assert(_.isFinite(value), this.typeAssertionMessage(variableName, 'number', value));
+ assert.assert(_.isFinite(value), assert.typeAssertionMessage(variableName, 'number', value));
},
isBoolean(variableName: string, value: boolean): void {
- this.assert(_.isBoolean(value), this.typeAssertionMessage(variableName, 'boolean', value));
+ assert.assert(_.isBoolean(value), assert.typeAssertionMessage(variableName, 'boolean', value));
},
isWeb3Provider(variableName: string, value: any): void {
const isWeb3Provider = _.isFunction(value.send) || _.isFunction(value.sendAsync);
- this.assert(isWeb3Provider, this.typeAssertionMessage(variableName, 'Provider', value));
+ assert.assert(isWeb3Provider, assert.typeAssertionMessage(variableName, 'Provider', value));
},
doesConformToSchema(variableName: string, value: any, schema: Schema, subSchemas?: Schema[]): void {
if (_.isUndefined(value)) {
@@ -76,15 +76,15 @@ export const assert = {
const msg = `Expected ${variableName} to conform to schema ${schema.id}
Encountered: ${JSON.stringify(value, null, '\t')}
Validation errors: ${validationResult.errors.join(', ')}`;
- this.assert(!hasValidationErrors, msg);
+ assert.assert(!hasValidationErrors, msg);
},
isWebUri(variableName: string, value: any): void {
const isValidUrl = !_.isUndefined(validUrl.isWebUri(value));
- this.assert(isValidUrl, this.typeAssertionMessage(variableName, 'web uri', value));
+ assert.assert(isValidUrl, assert.typeAssertionMessage(variableName, 'web uri', value));
},
isUri(variableName: string, value: any): void {
const isValidUri = !_.isUndefined(validUrl.isUri(value));
- this.assert(isValidUri, this.typeAssertionMessage(variableName, 'uri', value));
+ assert.assert(isValidUri, assert.typeAssertionMessage(variableName, 'uri', value));
},
assert(condition: boolean, message: string): void {
if (!condition) {