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

v2.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(reqOrFieldValues, fieldName, options)

Extracts a field from req.params, req.query, or req.body, then runs validations according to the provided options. You can either pass one of those field containers directly as the first argument, or a req object. In that case, params, query, and body will be searched for the passed fieldName.

example:

const uuid = validField(req, 'uuid', { minLength: 36 });
const parentId = validField(req.params, 'parent_id', { numericality: { onlyInteger: true, greaterThan: 0 } });
const id = validField(req, 'id', { match: /^[1-9]\d*$/ });
const orderBy = validField(req.query, 'orderBy', { includedIn: ['name', 'email', 'status'] });
const statuses = validField(req.query, 'statuses[]', { includedIn: ['invited', 'active'] });
const firstName = validField(req.body, 'firstName', { minLength: 5 });

Parameters

  • reqOrFieldValues: A request-like object with params, query, and body, or a direct field container such as req.params, req.query, or req.body.
  • fieldName: The field name to retrieve from the request object or direct field container.
  • options: An optional object containing validation requirements. Possible values for the options argument include:
    • optional: boolean - Allows the field to be omitted even when other validators such as minLength are configured.
    • 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.
    • match: RegExp - Validates the field value against a regular expression.
    • numericality: boolean | object - Converts the field to a number and validates numeric constraints. Supported object keys: onlyInteger, greaterThan, greaterThanOrEqualTo, lessThan, lessThanOrEqualTo.
    • includedIn: string[] - An array of valid strings that the field value must match to pass validation.

Return Value

  • If valid, returns the string, number, string array, or number array (in case of fields that use [] notation).
  • Returns undefined if the field is not required and not present, or if optional: true is set and the field is omitted.
  • 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 unless optional: true is set.

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

  • Check pattern: If options.match is defined, throws an error if the field’s value does not match the provided regular expression.

  • Check numericality: If options.numericality is defined, converts the field to a number and throws an error if it is not numeric or does not satisfy the configured numeric constraints.

  • 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, options)

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);
const alternateEmail = validEmail(req, { optional: true });

Parameters

  • req: A request-like object with query and body.
  • options: Optional configuration.
    • optional: boolean - Allows email to be omitted. If present, it is still validated.

Return Value

  • Returns a valid email string if validation passes.
  • Returns undefined if optional: true is set and the email is missing.
  • Throws an error if the email is invalid, or if it is missing without optional: true.

Behavior

  • Checks presence: Throws an error emailRequired if the field email is not found in either req.query or req.body, unless optional: true is set.
  • 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