diff options
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/assert.ts | 4 | ||||
-rw-r--r-- | src/utils/utils.ts | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/utils/assert.ts b/src/utils/assert.ts index 1baf572d1..0088b3b13 100644 --- a/src/utils/assert.ts +++ b/src/utils/assert.ts @@ -2,6 +2,7 @@ import * as _ from 'lodash'; import * as BigNumber from 'bignumber.js'; import * as Web3 from 'web3'; import {SchemaValidator} from './schema_validator'; +import {utils} from './utils'; const HEX_REGEX = /^0x[0-9A-F]*$/i; @@ -27,6 +28,9 @@ export const assert = { isNumber(variableName: string, value: number): void { this.assert(_.isFinite(value), this.typeAssertionMessage(variableName, 'number', value)); }, + isValidOrderHash(variableName: string, value: string): void { + this.assert(utils.isValidOrderHash(value), this.typeAssertionMessage(variableName, 'orderHash', value)); + }, doesConformToSchema(variableName: string, value: object, schema: Schema): void { const schemaValidator = new SchemaValidator(); const validationResult = schemaValidator.validate(value, schema); diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 336eaf7bb..e6840a624 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -18,4 +18,8 @@ export const utils = { isParityNode(nodeVersion: string): boolean { return _.includes(nodeVersion, 'Parity'); }, + isValidOrderHash(orderHashHex: string) { + const isValid = /^0x[0-9A-F]{64}$/i.test(orderHashHex); + return isValid; + }, }; |