aboutsummaryrefslogtreecommitdiffstats
path: root/src/ts/utils/assert.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-05-25 19:57:40 +0800
committerGitHub <noreply@github.com>2017-05-25 19:57:40 +0800
commitf7b8378a6eb4b4c6c3461ff677723869c67a4753 (patch)
treeacd0984b53d3e47c094784e39cd24cbdd75b2b04 /src/ts/utils/assert.ts
parentdfb7b039f15d572ddf2e417f71ecb069114100a8 (diff)
parentf3cfd3e708608cc88f61fcb9c6c8b56fcfa9d030 (diff)
downloaddexon-sol-tools-f7b8378a6eb4b4c6c3461ff677723869c67a4753.tar
dexon-sol-tools-f7b8378a6eb4b4c6c3461ff677723869c67a4753.tar.gz
dexon-sol-tools-f7b8378a6eb4b4c6c3461ff677723869c67a4753.tar.bz2
dexon-sol-tools-f7b8378a6eb4b4c6c3461ff677723869c67a4753.tar.lz
dexon-sol-tools-f7b8378a6eb4b4c6c3461ff677723869c67a4753.tar.xz
dexon-sol-tools-f7b8378a6eb4b4c6c3461ff677723869c67a4753.tar.zst
dexon-sol-tools-f7b8378a6eb4b4c6c3461ff677723869c67a4753.zip
Merge pull request #11 from 0xProject/isValidOrderHash
Port isValidOrderHash and tests
Diffstat (limited to 'src/ts/utils/assert.ts')
-rw-r--r--src/ts/utils/assert.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/ts/utils/assert.ts b/src/ts/utils/assert.ts
index 972047118..2f52c6a3b 100644
--- a/src/ts/utils/assert.ts
+++ b/src/ts/utils/assert.ts
@@ -3,6 +3,8 @@ import * as BigNumber from 'bignumber.js';
import Web3 = require('web3');
import {SchemaValidator} from './schema_validator';
+const HEX_REGEX = /^0x[0-9A-F]*$/i;
+
export const assert = {
isBigNumber(variableName: string, value: BigNumber.BigNumber) {
const isBigNumber = _.isObject(value) && value.isBigNumber;
@@ -11,7 +13,11 @@ export const assert = {
isString(variableName: string, value: string) {
this.assert(_.isString(value), this.typeAssertionMessage(variableName, 'string', value));
},
- isETHAddressHex(variableName: string, value: ETHAddressHex) {
+ isHexString(variableName: string, value: string) {
+ this.assert(_.isString(value) && HEX_REGEX.test(value),
+ this.typeAssertionMessage(variableName, 'HexString', value));
+ },
+ isETHAddressHex(variableName: string, value: string) {
const web3 = new Web3();
this.assert(web3.isAddress(value), this.typeAssertionMessage(variableName, 'ETHAddressHex', value));
},