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

request-data-validators

v1.1.3

Published

This is a package for validating request data in the express app

Readme

Dependencies

Express.js

Submited Data validation

You can use this validator by requiring the "request-validator" like below:

let RequestDataValidator = require('./request-data-validators');
let validator = new RequestDataValidator(req,res);

let data = {
    "value1": validator.body(request,true,'Value 1').type('int').val(),
    "value2": validator.body(request,true,'Value 2').type('int').allow([0,1]).val()
}

you have to call isValidate method to check that all data is validate

let is_validated = validator.isValidate()

if you provide true as parameter then it redirect to back by defalut with old data erros in flash. YOu can retrive old data and error like below

let errors = Req.flash('errors')[0],
let old = Req.flash('old')[0]

if you want to get the errors in json format

let errors = validator.errors.details;

Request validator methods:

| Methods | Parameters | Decription| |---------|------------|-----------| | get/params| key(string) | retrive the value url params | | body/post | key(string), isRequired(bool), name(string), custom_message(string) | retrive value of url params | | type | type(string) | validate the value type such as int, float,bool,number etc| | length | length(int), custom_message(string) | validate the value is fixed length | | minLength | length(int), custom_message(string)|validate minimum length of the value | | maxLength | length(int), custom_message(string)|validate maximum length of the value | | minNumber | value(int), custom_message(string)|validate minimum number of the value | | maxNumber | value(int),custom_message(string)|validate maximum number of the value | | disallow | values(array), custom_message(string) | validate if disallow value is provided | | allow | values(array), custom_message(string) | validate the value is from allowed list | | custom | callback function, custom_message(string) | return true of false from the callback methods | | sameAs | key(string), custom_message(string) | check the value is same as others value | | format | type(string="array_obj"), format(array of object),custom_message(string) | validate the provide array is correct format | | val| N/A | finally return the value | | validate| auto_response(bool) | validate all required validation and return the result |

Example of format array :

You have to pass this type of format array in calling the format method

[{ "update_quantity": 'int', "inventory_item_id": "int" }]

List of the value of type in type method:

| type | Decription | |------|------------| | int| Accept only integer type value | | string | Accept only string type value | | email | Accept only email type value | | date | Accept only date type value | | number | Accept only number type value | | boolean | Accept only boolean type value | | array_int | Accept only array int type value | | mobile_bd | Accept only valid mobile number of bangladesh |