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 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-red-contrib-request-validator

v1.0.0

Published

a node-red custom node to create schemas to validate incoming requests data.

Readme

node-red-contrib-request-validator

A Node-RED custom node, to create schema for validate request fields

image image image

image image

Donate

Requirements

  • node-red version >=1.3.7

Installation

Install via Node-RED Manage Palette

node-red-contrib-request-validator

Install via npm

$ cd ~/.node-red
$ npm install node-red-contrib-request-validator
# then restart node-red

Usage

Create Schemas to validate request method, body and query parameters. Schemas are configured in this node Properties.

Properties

  • Method (GET, POST, PUT, DELETE) - the expected method of the request to be validated.

  • Query Params (json) - the Schema of the expected query params.

  • Body Params (json) - the Schema of the expected body params.

Outputs

  1. Valid Request (top output)
    • msg (any) - the original msg of request.
  2. Invalid Request (bottom output)
    • payload (json) - the error message.
    • statusCode (400 | 500) - the status code of error.

Schema

Schema Params

  • type (string | number | boolean | array | date | any) - the type of the param.
  • required (true | false) - whether the param is required or not.
  • subtype (string | number | boolean | date | any) - if the type is array, the subtype of the array elements.
  • specifications (json) - the specifications of the param.

Specifications

a specifications is a json object, used to validate specifics aspects of the param. Has the following properties:

  • min (number) - the minimum value of the param. If the param is an String, the min length of the param.
  • max (number) - the maximum value of the param. If the param is an String, the max length - the param.
  • float (true | false) - whether the param is a float number
  • format ( "email" | "phone" | "date" | "cnpj" | "cpf" ) - the format of the string param.

Examples

Body schema example

    {
        "name": {
            "type": "string",
            "required": true
        },
        "phoneList": {
            "type": "array",
            "subtype": "string"
        }
    }
Verification steps
  1. Verify that the request body exist.
  2. Verify if exist property name and its type is string.
  3. If exist property addressList verify if its type is array and its subtype is string.
  4. If all the validations are passed, send the original msg to the node connected to the top output.
  5. If any validation fails, send the error message to the node connected to the bottom output.

Query specific schema example

    {
        "id": {
            "type": "number",
            "required": true,
            "specifications":{
                "min": 1,
                "float": false,
            }
        }
    }
Verification steps
  1. Verify that the request query exist.
  2. Verify if exist property id.
  3. Verify if the query string can be converted to a number.
  4. Verify if a id is Integer number.
  5. Verify if a id is greater or equal than 1.