hapi-joi-express
TypeScript icon, indicating that this package has built-in type declarations

1.3.2 • Public • Published

Express middleware for handling Joi validations with typescript support.

Middleware that helps with the property validation, if the test passes, next function in the row will be invoked, otherwise, the server responds with 422 status and JSON object with a list of errors.

API

const app = require("express")();
const { bodyValidation } = require("hapi-joi-express");
// also available: { paramsValidation, queryValidation }
 
const schema = Joi.object({ username: Joi.string().required() });
 
app.post("/login", bodyValidation(schema), (req, res) => res.json({ hello: "world" }));

ES6 imports

import express from "express";
import { queryValidation } from "hapi-joi-express";
// also available: { paramsValidation, queryValidation }
 
const app = express();
 
const schema = Joi.object({ username: Joi.string().required() });
 
app.post("/login", bodyValidation(schema), (req, res) => res.json({ hello: "world" }));

Package Sidebar

Install

npm i hapi-joi-express

Weekly Downloads

0

Version

1.3.2

License

ISC

Unpacked Size

2.87 kB

Total Files

4

Last publish

Collaborators

  • dedadev