{"repo":"vacekj/express-json-validator-middleware","free":true,"listed":false,"github":"https://github.com/vacekj/express-json-validator-middleware","clone":"git clone https://github.com/vacekj/express-json-validator-middleware.git","description":"Express middleware for validating requests against JSON schema","language":"JavaScript","stars":158,"topics":["expressjs","express-middleware","json","json-schema","ajv","json-schemas","express"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Express JSON Validator Middleware Express middleware for validating requests against JSON schemas with Ajv. Why validate with JSON schemas? - Expressive — JSON schemas are an expressive way to describe data structures. - Standard — JSON schemas are portable. There are validator implementations in many languages. - Separate validation — Avoid the need to handle request validation in your route handlers. - Error messaging — Ajv provides rich and descriptive error objects. - Documentation — Schemas can help document your application. Requirements - Node.js = v14 Installation If you're upgrading from v2 to v3, make sure you read the migration notes. Getting started If you need to add formats, plugins, or custom keywords to Ajv, create a Validator instance first, configure validator.ajv , and only then call validate() . See Ajv instance. Coming from express-jsonschema ? Read the migration notes. Schemas in TypeScript If you're writing JSON schemas in TypeScript, you'll need to use the AllowedSchema type and this can be combined with ajv's recommended JSONSchemaType type e.g. This is required so TypeScript doesn't attempt to widen the types of values in the schema object. If you omit this type, TypeScript will raise an error. See issues #39 and #102 for more background. Error handling On encountering invalid data, the validator will call next() with a ValidationError object. It is recommended to setup a general error handler for your app where you handle ValidationError errors. Exa","default_branch":null,"files":null,"tree":[],"storefront":"/r/vacekj","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/vacekj/express-json-validator-middleware/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}