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

vldt

v0.2.0

Published

Object validation made easy

Readme

vldt

Object validation made easy.

Defining Fields

To define a field use a string formatted like so:

[<prefix>]<type>[<array_indicator>][<min>][<max>]

Then use this string to create a field:

let field = Field.create(<definition>)

For instance:

let field = Field.create("*int>10")

Prefixes

  • * : required. Required fields need to exist and contain a valid other than null or undefined.
  • - : hidden. Hidden fields are not projected (see projection).
  • ! : unique. Unique fields are not checked by VLDT itself. Use the field's isUnique property when saving data to a database for instance.

Types

  • string
  • number - accepts both, integers and floats
  • int - accepts only integers (i.e. 1.3 would not be accepted)
  • float - accepts floats (basically the same as number. When projected values are forced into float format however)
  • bool - true, false, and all truthy values (https://developer.mozilla.org/en-US/docs/Glossary/Truthy)
  • email

Array Indicator

If a field is supposed to be an array, use the array indicator []. For instance:

'string[]'

Min / Max

To require a minimum / maximum value, use > and <. For instance:

  • int>1 - the value needs to be greater than 1.
  • int<10 - the value needs to be smaller than 10
  • int>1<10 - the value needs to be greater than 1 and smaller than 10

Notes:

  • If the type is string, the length of the string is checked.
  • If the type is bool, min and max are ignored
  • If the type is email, min and max are ignored
  • When dealing with an array field, the min and max are used to check the values in the array (not the length of the array. Array length validation will implemented at a later point)

Validation

After creating a field, use its validate(<value>) method:

let result = field.validate(8)

The validation result is an object with two properties:

  • isValid - a bool set to true if validation was successful, or set to false if not
  • errors - an array containing an object for each validation error. Each of these objects has two properties:
    • message: a string containing a descriptive text of the error encountered
    • reason: a string expressing in one word the reason for the error. The following values are used:
      • required: a value was required but not given
      • type: the value was of the wrong type
      • format: the value was not formatted correctly (e.g. a wrongly formatted e-mail address)

Roadmap

  • Array length validation
  • Embedded validation