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

light-paradate

v1.1.2

Published

Lightweight request params validator

Readme

light-paradate

Lightweight request params validator

Table of Contents

Introduction

This library helps validate incoming request data by checking for:

  • Presence (required fields)
  • Minimum length of string fields
  • Value inclusion in a predefined list
  • Email format validation

Support

  • TypeScript Support: Includes type definitions.
  • CJM, ESM support: Supports both CommonJS and ES modules.

Features

Installation

npm install light-paradate

Or with Yarn:

yarn add light-paradate

Usage

validField

validField(req, fieldName, options)

Extracts a field from req.query or req.body, then runs validations according to the provided options.

example:

const uuid = validField(req, 'uuid', { minLength: 36 });
const orderBy = validField(req, 'orderBy', { includedIn: ['name', 'email', 'status'] });
const statuses = validField(req, 'statuses[]', { includedIn: ['invited', 'active'] });
const firstName = validField(req, 'firstName', { minLength: 5 });

Parameters

  • req: A request-like object with query and body.
  • fieldName: The field name to retrieve from req.query or req.body.
  • options: An optional object containing validation requirements. Possible values for the options argument include:
    • required: boolean - Indicates whether the field must have a non-empty value.
    • minLength: number - Specifies the minimum length the field value should have.
    • maxLength: number - Specifies the maximum length the field value can have.
    • includedIn: string[] - An array of valid strings that the field value must match to pass validation.

Return Value

  • If valid, returns the string or string array (in case of fields that use [] notation).
  • Returns undefined if the field is not required and not present.
  • Throws an error if validation fails.

Behavior

  • Check presence: If options.required is set or if options.minLength is defined, the field must be present or an error will be thrown.

  • Check length: If options.minLength is set, throws an error if the field’s value is shorter than the specified length.

  • Check inclusion: If options.includedIn is defined, throws an error if the field’s value (or values) are not in the specified list.

    Array fields: If your field name ends with [] (e.g., statuses[]), the utility will treat the field as an Array. If there is only one value, it will be returned in a single-element array.

validEmail

validEmail(req)

Extracts and validates the "email" field from req.query or req.body, ensuring it is both present and syntactically valid.

example:

const email = validEmail(req);

Parameters

  • req: A request-like object with query and body.

Return Value

  • Returns a valid email string if validation passes.
  • Throws an error if the email is missing or invalid.

Behavior

  • Checks presence: Throws an error emailRequired if the field email is not found in either req.query or req.body.
  • Checks format: Uses the email-validator package under the hood to ensure the format is correct. If invalid, throws an error emailInvalid.

License

This project is licensed under the MIT License.

Package URL

https://www.npmjs.com/package/light-paradate

Code repository

https://bitbucket.org/endeavia/light-paradate/src/master/

Author

Tamás Kamarás