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

Error: strict mode

berni-mad opened this issue · comments

commented

Due to the upgrade from v2 to v3, i am facing some validation issues that were previously not present. In order to maintain consistency, I would like to refactor my code as little as possible. Is there a way to avoid those kind of errors?

Error: strict mode: unknown keyword XXX

Ajv, which this library uses under the hood, now executes in strict mode by default. You can pass Ajv options when you create a Validator instance. For example, to allow unknown keywords in your schema (i.e. ones not in the JSON Schema specification):

const validator = new Validator({
   strictSchema: false
})

See the Ajv documentation for all strict mode options: https://ajv.js.org/strict-mode.html