simonplend / express-json-validator-middleware

Express middleware for validating requests against JSON schema

Home Page:https://npm.im/express-json-validator-middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pass Ajv instance to Validator constructor

pstadler opened this issue · comments

First of all, thank you for providing this middleware. I've been using it across multiple projects.

How about letting users pass an Ajv instance to Validator? In my case this would be an instance of the 2019-09 draft version[1].

const Ajv2019 = require('ajv/dist/2019')
const ajv = new Ajv2019()

const validator = new Validator(ajv)

[1] https://ajv.js.org/json-schema.html#draft-2019-09

Cheers
Patrick

Glad to hear you're finding this package helpful!

That's a nice idea — if you're able to open a PR for this I'd be very happy to review it.