diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-09-19 06:57:05 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-09-19 06:57:05 +0800 |
commit | 93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25 (patch) | |
tree | eb75ab7ab1a3a2e4b4c588e2f5eb3f976b9a1a68 /packages/asset-buyer/src/utils | |
parent | fd4b4f8f8289d1e5a873ff5aa0aa9f7ac6a2ba08 (diff) | |
download | dexon-sol-tools-93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25.tar dexon-sol-tools-93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25.tar.gz dexon-sol-tools-93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25.tar.bz2 dexon-sol-tools-93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25.tar.lz dexon-sol-tools-93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25.tar.xz dexon-sol-tools-93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25.tar.zst dexon-sol-tools-93f7e33f6a1d0a056198a9f22bcb10ef3e4f4f25.zip |
Add isValidPercentage assert
Diffstat (limited to 'packages/asset-buyer/src/utils')
-rw-r--r-- | packages/asset-buyer/src/utils/assert.ts | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/packages/asset-buyer/src/utils/assert.ts b/packages/asset-buyer/src/utils/assert.ts index edc90608c..745ba726f 100644 --- a/packages/asset-buyer/src/utils/assert.ts +++ b/packages/asset-buyer/src/utils/assert.ts @@ -41,4 +41,11 @@ export const assert = { `Expected all orders in ${variableName} to have the same makerAssetData and takerAssetData.`, ); }, + isValidPercentage(variableName: string, percentage: number): void { + assert.isNumber(variableName, percentage); + assert.assert( + percentage >= 0 && percentage <= 1, + `Expected ${variableName} to be between 0 and 1, but is ${percentage}`, + ); + }, }; |