Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backend-validation-express

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backend-validation-express - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

4

lib/index.d.ts

@@ -9,3 +9,3 @@ import { NextFunction, Request, Response } from "express";

}
declare const Validator: (validationSchema: IValidationSchema) => (req: Request, res: Response, next: NextFunction) => Response<any, Record<string, any>> | undefined;
export default Validator;
declare const validator: (validationSchema: IValidationSchema) => (req: Request, res: Response, next: NextFunction) => Response<any, Record<string, any>> | undefined;
export default { validator, Joi };
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Validator = (validationSchema) => {
exports.Joi = exports.validator = void 0;
const joi_1 = __importDefault(require("joi"));
exports.Joi = joi_1.default;
// validation middleware
const validator = (validationSchema) => {
return (req, res, next) => {
var _a;
try {
let errorMessages = {};
const errorMessages = {};
let errorExist = false;

@@ -33,3 +40,3 @@ (_a = Object.keys(validationSchema)) === null || _a === void 0 ? void 0 : _a.map((key) => {

wrap: {
label: "",
label: '',
},

@@ -40,3 +47,3 @@ },

errorExist = true;
let messages = {};
const messages = {};
(_a = error.details) === null || _a === void 0 ? void 0 : _a.map((err) => {

@@ -51,3 +58,3 @@ messages[err.path[0]] = err.message;

if (errorExist) {
return res.status(422).send({ success: false, errors: errorMessages, message: "Validation Error!" });
return res.status(422).send({ success: false, errors: errorMessages, message: 'Validation Error!' });
}

@@ -61,2 +68,2 @@ next();

};
exports.default = Validator;
exports.validator = validator;
{
"name": "backend-validation-express",
"version": "1.0.2",
"version": "1.0.3",
"description": "Request data validation middleware using Joi for express in backend",

@@ -10,3 +10,3 @@ "main": "lib/index.js",

"format": "prettier --write \"src/**/*.ts\" ",
"lint": "tslint -p tsconfig.json",
"lint": "tsc",
"prepare": "npm run build",

@@ -13,0 +13,0 @@ "prepublishOnly": "npm run lint",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc