Socket
Socket
Sign inDemoInstall

m2e-validator

Package Overview
Dependencies
4
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    m2e-validator

Convert mongoose schema into an express-validator chain


Version published
Weekly downloads
14
increased by600%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

🔌 Mongoose to Express-Validator adapter

Status Coverage Status

This package converts Mongoose schema into a validation chain for Express. Currently, it supports most default schema types as well as a few custom ones. For instance, schema types named Email or Phone match validator's implementation. See the full list of supported properties below.

The plugin

This module works through a custom Mongoose plugin that appends two static methods, getSchemaPaths and getChildPaths. Both work recursively and support child and discriminator schemas. To access a discriminator, though, the request object must contain a reference to its key. See the examples below for more detail.

// coming soon

The schemas

All schema types support required and systemOnly properties. The latter omits the field from validation altogether.

NameOptionsNotes
StringminLength, maxLength, enumAuto escapes and trims
Numbermin, max
ObjectId
SchemaArray
DateAuto converts to ISO string
BooleanAuto converts any non-falsy value to true
URL--Auto normalizes
Email--Auto normalizes
Phone--

FAQs

Last updated on 26 Feb 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc