From d574f040cd993941306221b0abda52551260dc17 Mon Sep 17 00:00:00 2001 From: Ivano Picco Date: Tue, 19 Jul 2022 14:57:10 +0200 Subject: [PATCH] Fix for moleculerjs/moleculer#1094 --- index.js | 10 ++++------ index.test.js | 3 +-- package.json | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 1606e35..bfe9a19 100644 --- a/index.js +++ b/index.js @@ -2,17 +2,15 @@ const Ajv = require("ajv"); const addFormats = require("ajv-formats"); const addKeywords = require("ajv-keywords"); -const BaseValidator = require("moleculer/src/validators/base"); -const FallbackValidator = require("moleculer/src/validators/fastest"); -const {ValidationError} = require("moleculer/src/errors"); +const { Validators, Errors: { ValidationError } } = require("moleculer"); -class AjvValidator extends BaseValidator { - constructor (options) { +class AjvValidator extends Validators.Base { + constructor (options = {}) { super(); this.validator = new Ajv(options); addKeywords(this.validator); addFormats(this.validator); - this.fallbackValidator = new FallbackValidator(); + this.fallbackValidator = new Validators.Fastest(); } compile (schema) { diff --git a/index.test.js b/index.test.js index 7037a43..bce8611 100644 --- a/index.test.js +++ b/index.test.js @@ -1,7 +1,6 @@ "use strict"; -const { ServiceBroker } = require("moleculer"); -const { ValidationError } = require("moleculer").Errors; +const { ServiceBroker, Errors: { ValidationError }} = require("moleculer"); beforeAll(async () => {}); afterAll(async () => {}); diff --git a/package.json b/package.json index 0180767..f3ae542 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "moleculer-json-schema-validator", - "version": "3.0.0", + "version": "3.0.1", "description": "json-schema validator for moleculer", "keywords": [ "moleculer",