asyncapi-validator
Advanced tools
Comparing version
Change Log | ||
========== | ||
Version 3.1.1 *(2021-09-30)* | ||
---------------------------- | ||
* Add TS types | ||
* Fix JSDocs for `fromSource()` | ||
Version 3.1.0 *(2021-08-22)* | ||
@@ -5,0 +10,0 @@ ---------------------------- |
{ | ||
"name": "asyncapi-validator", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "message validator through asyncapi schema", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"scripts": { | ||
@@ -7,0 +8,0 @@ "test": "jest", |
@@ -8,7 +8,10 @@ const ValidationError = require('./ValidationError') | ||
* @param {string} source | ||
* @param {{ msgIdentifier?: string ; ignoreArray?: boolean }} options | ||
* @param {{ msgIdentifier: string ; ignoreArray?: boolean }} options | ||
* @returns {Promise<MessageValidator>} | ||
*/ | ||
this.fromSource = async (source, options = {}) => { | ||
this.fromSource = async (source, options) => { | ||
const {_json: schema} = await Parser.parse(source) | ||
if (!options || !options.msgIdentifier) { | ||
throw new ValidationError('"msgIdentifier" is required') | ||
} | ||
const channels = constructsChannels(schema, options.msgIdentifier) | ||
@@ -25,5 +28,2 @@ return new MessageValidator(schema, options, channels) | ||
const channels = {} | ||
if (!msgIdentifier) { | ||
throw new ValidationError('"msgIdentifier" is required') | ||
} | ||
@@ -30,0 +30,0 @@ Object.keys(schema.channels).forEach(c => { |
95928
0.54%30
3.45%738
1.93%