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

express-form

Package Overview
Dependencies
Maintainers
0
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-form

Form validation and data filtering for Express

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
103
increased by17.05%
Maintainers
0
Weekly downloads
 
Created
Source

Express Form provides data filtering and validation as route middleware to your Express applications.

Usage:

var form = require("express-form"),
    filter = form.filter,
    validate = form.validate;

var app = express.createServer();

app.configure(function() {
  app.use(express.bodyDecoder());
  app.use(app.router);
});

app.post(

  // Route
  '/user',
  
  // Form filter and validation middleware
  form(
    filter("username").trim(),
    validate("username").required().is(/^[a-z]+$/),
    filter("password").trim(),
    validate("password").required().is(/^[0-9]+$/)
  ),
  
  // Express request handler now gets filtered and validated body
  function(req, res){
    // Now we can inspect the errors!  
    if (!req.form.isValid) {
      // Handle errors
      console.log(req.form.errors);
    }
  }
);

Documentation:

Coming soon! For now, just read the source.

Installation:

npm install express-form

Keywords

FAQs

Package last updated on 09 Jan 2011

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