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

@ajoelp/express-validator

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ajoelp/express-validator

Validation middleware for express

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Express Validator

Installation

## npm
npm i @ajoelp/express-validator

## yarn
yarn add @ajoelp/express-validator

Usage

import express from 'express';
import {body, query, params, validationResponseMiddleware} from '@ajoelp/express-validator'

const app = express();

app.get(
    '/',
    [
        query({
            'search': ['required', 'string'],
        }),
        params({
            'userId': ['required', 'number'],
        }),
        body({
            'email': ['required', 'email'],
            'password': ['required', { type: 'string', message: 'This needs to be a string'}],
        }),
        validationResponseMiddleware,
        (req, res) => res.send()
    ]
)

// express app setup...

Rules

RuleRule StringRule Object
RequiredRulerequired{ type: 'required', message: 'This is the message'}
StringRulestring{ type: 'string', message: 'This is the message'}
NumberRulenumber{ type: 'number', message: 'This is the message'}
MinRule{ type: 'min', value: 3, message: 'This is the message'}
MaxRule{ type: 'max', value: 4, message: 'This is the message'}
BooleanRuleboolean{ type: 'boolean', message: 'This is the message'}
EmailRuleemail{ type: 'email', regex: new RegExp(), message: 'This is the message'}
DateRuledate{ type: 'date', message: 'This is the message'}
NullableRulenullable
CustomRule{ type: 'custom', rule: (value: string, request: Request) => Promise<boolean>, message: 'This is the message'}

Keywords

FAQs

Package last updated on 01 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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