npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vqq/exp-validator

v1.0.4

Published

Validator for expressJS

Readme

Exp Validtor

Validator for Express

Build Status

Exp-Validtor is a wrapper for validator package to use like a Express middleware. Here is a list of the validators currently available.

Features

  • Cover all validator rules.
  • Easy to use like a Express middleware.
  • Easy to custom rules.
  • Easy to custom messages and attributes.

Installation

Install package with npm.

npm i @vqq/exp-validator

Or yarn

yarn add @vqq/exp-validator

Usage

Require package to main server.

const expValidator = require('@vqq/exp-validator');

Set up locale for validator

expValidator.locale.readMessages();

You can set locale code or set path to your language file by json format.

expValidator.locale.setLocale('jp').readMessages();
expValidator.locale.setLocale('jp').setPath('path/:locale/filename.json').readMessages();

Set your own custom rules by setCustomRules

expValidator.setCustomRules({
    isTest: function(str, param1, param2) { return str === param1 && param2.check === 'check param 2'; }
});

Finally, Use your Exp-Validator like a middleware.

const app = express();
app.post('/create', expValidator.validate({
    email: [
        'nullable',
        'isEmail',
        {isByteLength: [{min:15, max: 50 }]}
    ],
    test: [
        {isTest: ['check param 1', {check: 'check param 2'}]}
    ]
})
,function (req, res) {
    // Your code here
});

Some options you can change.

Change options by passing a object after rules. data option

expValidator.validate({
    email: [
        'isEmail'
    ],
}, {data: {
    email: '[email protected]'
}});

method option (COOKIE, HEADER)

expValidator.validate({
    email: [
        'isEmail'
    ],
}, {method: 'COOKIE'});

messages and attributes options

expValidator.validate({
    email: [
        'isEmail'
    ],
    test: [
        {isTest: ['check param 1', {check: 'check param 2'}]}
    ]
}, {
    messages: {
        'isEmail': 'The :attribute must be a valid email address.',
        'test.isTest': 'The :attribute must be equal "%(params[0])s" and param 2 must be equal "%(params[1].check)s".',
    },
    attributes: {
        'email': 'Email',
        'test': 'Test Param'
    }
});

If you want to response all error messages for every rule. you can set checkFirst option to false.

expValidator.validate({
    email: [
        'nullable',
        'isEmail',
        {isByteLength: [{min:15, max: 50 }]}
    ]
}, {checkFirst: false})

nullable rule is special rule. It won't check other rules if your field is empty.

Advanced usage

You can use validator by your own way. Like this:

const express = require('express');
const expValidator = require('@vqq/exp-validator');

const app = express();
// expValidator.locale.readMessages();
expValidator.setCustomRules({
    isTest: function(str, param1, param2) { return str === param1 && param2.check === 'check param 2'; }
});
expValidator.validator.setMessages({
    'isEmail': 'The :attribute must be a valid email address.',
    'test.isTest': 'The :attribute must be equal "%(params[0])s" and param 2 must be equal "%(params[1].check)s".',
}).setAttributes({
    'email': 'Email',
    'test': 'Test Param'
});

app.post('/create', function (req, res) {
    const result = expValidator.validator.setData({
        email: 'youremail@domain',
        test: 'check param 2'
    }).setRules({
         email: [
            'isEmail'
        ],
        test: [
            {isTest: ['check param 1', {check: 'check param 2'}]}
        ]
    }).validate();
    if (result) {
        return res.status(422).send(result);
    }
    // Your code here
    return res.status(200).send('success');
});