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

@form-validator-js/validators

v1.1.0

Published

Built-in validators for form-validator-js: required, minLength, maxLength, pattern, equalsTo, checkedCount, numeric, min, max, step.

Readme

@form-validator-js/validators

Built-in validators for form-validator-js: required, minLength, maxLength, pattern, equalsTo, checkedCount, numeric, min, max, step. Peer-depends on @form-validator-js/core, pinned to the exact same version.

Install

npm install @form-validator-js/core @form-validator-js/validators

Quick start

<form id="signin">
  <input id="email"    name="email"    type="email"
         data-validation="required;maxLength(254)">
  <input id="password" name="password" type="password"
         data-validation="required;minLength(8)">
  <p id="errors"></p>
  <button>Sign in</button>
</form>
import { FormValidator } from '@form-validator-js/core';
import { required, minLength, maxLength } from '@form-validator-js/validators';

const form = document.getElementById('signin') as HTMLFormElement;
const errors = document.getElementById('errors') as HTMLElement;

new FormValidator({
  form,
  validatorDeclarations: { required, minLength, maxLength },
  onErrorMessageListChanged: (el, msgs) => {
    if (el === form) return;
    errors.textContent = msgs.join('; ');
  },
});

For the FormValidator constructor, the validator contract, async validation, validation timing, and accessibility, see @form-validator-js/core.

"Text-like input" vocabulary

In the table below, "text-like input" means any of: text, password, tel, email, url, search, number, date, time, datetime-local, month, week, color, range, hidden. An <input> without a type attribute defaults to text.

File inputs

<input type="file"> is supported by required only (value non-empty maps to "file is selected"). For real file validation — size, MIME type, count — write a custom validator that reads target.files. minLength / maxLength / pattern reject type="file" because they would otherwise check the browser's fake-path string ('C:\fakepath\…'), which isn't useful. numeric / min / max / step likewise reject type="file".

Built-in validators

| Name | DSL | Argument | Notes | | --- | --- | --- | --- | | required | required | none | Text-like input, <textarea>, <select>: non-empty value. Checkbox/radio: at least one in the group is checked. type="file": at least one file selected. | | minLength | minLength(3) | min character count | Text-like input or <textarea>. Counts UTF-16 code units (matches native minlength). | | maxLength | maxLength(20) | max character count | Text-like input or <textarea>. Counts UTF-16 code units (matches native maxlength). | | pattern | pattern(\d{4}) | regex source | Text-like input or <textarea>. The regex is auto-anchored (^(?:…)$) so it must match the entire value, matching native pattern. Empty value passes — combine with required to forbid empty. | | equalsTo | equalsTo(password) | id of another field | Cross-field equality, e.g. password confirmation. Strict === — Unicode normalization is not applied ('café' in NFC and NFD are not equal). Intentional, so password matching is byte-exact. | | checkedCount | checkedCount(1,3) | min, max, or min,max | Group min/max for checkboxes / radios. ,N means up to N. N, means N or more. | | numeric | numeric | none | type="number", date, time, month, week, datetime-local. Rejects unparseable input (validity.badInput, plus a defensive parse-side check). Empty value passes — compose with required. | | min | min(10) / min(2026-01-01) | lower bound | type="number", date, time, month, week, datetime-local. Bound is parsed in the input's own format. Empty / bad-input passes (compose with required / numeric). | | max | max(100) / max(2026-12-31) | upper bound | Same types as min. Empty / bad-input passes. | | step | step(0.5) / step(7, 2026-01-05) / step(900, 09:00) | step or step,base | Same types as min. The step argument is in the type's natural unit (number: 1; date: 1 day; time: 1 s; month: 1 month; week: 1 week; datetime-local: 1 s) and is scaled to compare against the value. Default base is 0 — except week, where default base is the Monday of 1970-W01 so the grid lines up with valid week values. Compared within 1e-9 to absorb FP error. Empty / bad-input passes. |

DSL syntax

Validators are declared on a control via the data-validation attribute. Names are separated by ;, ,, or whitespace; arguments live inside parentheses immediately after the name. Examples:

required
required;minLength(3)
required, minLength(3)
checkedCount(1,3)
pattern(\d{4}-\d{2}-\d{2})

Inside (...), ; and , are allowed (e.g. in regex sources or in checkedCount(1,3)) — the parser only treats them as separators outside the parentheses. The closing ) must be followed by ;, ,, or whitespace; if the attribute value ends right after ), a trailing separator is appended automatically.

License

MIT.