diff options
Diffstat (limited to 'packages/json-schemas/src')
-rw-r--r-- | packages/json-schemas/src/schema_validator.ts | 8 | ||||
-rw-r--r-- | packages/json-schemas/src/schemas.ts | 6 |
2 files changed, 13 insertions, 1 deletions
diff --git a/packages/json-schemas/src/schema_validator.ts b/packages/json-schemas/src/schema_validator.ts index 3f303137b..43647b594 100644 --- a/packages/json-schemas/src/schema_validator.ts +++ b/packages/json-schemas/src/schema_validator.ts @@ -8,12 +8,18 @@ import { schemas } from './schemas'; */ export class SchemaValidator { private readonly _validator: Validator; + private static _assertSchemaDefined(schema: Schema): void { + if (schema === undefined) { + throw new Error(`Cannot add undefined schema`); + } + } /** * Instantiates a SchemaValidator instance */ constructor() { this._validator = new Validator(); for (const schema of values(schemas)) { + SchemaValidator._assertSchemaDefined(schema); this._validator.addSchema(schema, schema.id); } } @@ -24,6 +30,7 @@ export class SchemaValidator { * @param schema The schema to add */ public addSchema(schema: Schema): void { + SchemaValidator._assertSchemaDefined(schema); this._validator.addSchema(schema, schema.id); } // In order to validate a complex JS object using jsonschema, we must replace any complex @@ -37,6 +44,7 @@ export class SchemaValidator { * @returns The results of the validation */ public validate(instance: any, schema: Schema): ValidatorResult { + SchemaValidator._assertSchemaDefined(schema); const jsonSchemaCompatibleObject = JSON.parse(JSON.stringify(instance)); return this._validator.validate(jsonSchemaCompatibleObject, schema); } diff --git a/packages/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts index 21a6f424c..9e8eb6959 100644 --- a/packages/json-schemas/src/schemas.ts +++ b/packages/json-schemas/src/schemas.ts @@ -8,7 +8,7 @@ import * as ecSignatureSchema from '../schemas/ec_signature_schema.json'; import * as eip712TypedDataSchema from '../schemas/eip712_typed_data_schema.json'; import * as hexSchema from '../schemas/hex_schema.json'; import * as indexFilterValuesSchema from '../schemas/index_filter_values_schema.json'; -import * as jsNumber from '../schemas/js_number.json'; +import * as jsNumber from '../schemas/js_number_schema.json'; import * as numberSchema from '../schemas/number_schema.json'; import * as orderCancellationRequestsSchema from '../schemas/order_cancel_schema.json'; import * as orderConfigRequestSchema from '../schemas/order_config_request_schema.json'; @@ -16,6 +16,8 @@ import * as orderFillOrKillRequestsSchema from '../schemas/order_fill_or_kill_re import * as orderFillRequestsSchema from '../schemas/order_fill_requests_schema.json'; import * as orderHashSchema from '../schemas/order_hash_schema.json'; import * as orderSchema from '../schemas/order_schema.json'; +import * as orderWatcherWebSocketRequestSchema from '../schemas/order_watcher_web_socket_request_schema.json'; +import * as orderWatcherWebSocketUtf8MessageSchema from '../schemas/order_watcher_web_socket_utf8_message_schema.json'; import * as orderBookRequestSchema from '../schemas/orderbook_request_schema.json'; import * as ordersRequestOptsSchema from '../schemas/orders_request_opts_schema.json'; import * as ordersSchema from '../schemas/orders_schema.json'; @@ -66,6 +68,8 @@ export const schemas = { jsNumber, requestOptsSchema, pagedRequestOptsSchema, + orderWatcherWebSocketRequestSchema, + orderWatcherWebSocketUtf8MessageSchema, ordersRequestOptsSchema, orderBookRequestSchema, orderConfigRequestSchema, |