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

input-is

v2.1.1

Published

Simple input validation

Downloads

116

Readme

input-is

Build Status Coverage Status

Simple input validation

Why?

Almost any project needs a form validation. This package simplifies your workflow.

Installation

npm i -S input-is

or

yarn add input-is

Usage

After installation you can import the package to your project and use a declarative way to validate your form inputs. The return value is always a boolean, e.g. true or false.

Here is a litte example:

import inputIs from 'input-is'; // const inputIs = require('input-is');

inputIs.email('hello'); // false
inputIs.email('example@mail.com'); // true

Functions:

date

Note: you have to pass the format of the date as second parameter to the function

This function validates if a form input is a valid date

return value: boolean

// valid formats:
// YYYY-MM-DD, MM-DD-YYYY,
// DD-MM-YYYY, YYYY/MM/DD,
// MM/DD/YYYY, DD/MM/YYYY,

inputIs.date('100/100/1000'); // false
inputIs.date('12/12/2017', 'DD/MM/YYYY'); // true

datetime

Note: you have to pass the format of the date as second parameter to the function

This function validates if a form input is a valid datetime

return value: boolean

// valid formats:
// YYYY-MM-DD hh:mm:ss, YYYY-MM-DD hh:mm,
// MM-DD-YYYY hh:mm:ss, MM-DD-YYYY hh:mm,
// DD-MM-YYYY hh:mm:ss, DD-MM-YYYY hh:mm,
// YYYY/MM/DD hh:mm:ss, YYYY/MM/DD hh:mm,
// MM/DD/YYYY hh:mm:ss, MM/DD/YYYY hh:mm,
// DD/MM/YYYY hh:mm:ss, DD/MM/YYYY hh:mm,

inputIs.datetime('12/12/2017'); // false
inputIs.datetime('12/12/2017 12:12:12', 'DD/MM/YYYY'); // true

email

This function validates if a form input is a valid email

return value: boolean

inputIs.email('example.mail.com'); // false
inputIs.email('example@mail.com'); // true

exactly

This function validates if a form input is a exactly the same as a target

return value: boolean

inputIs.exactly('this should be', 'exactly like this target'); // false
inputIs.exactly('exactly the same', 'exactly the same'); // true

filled

This function validates if a form input is filled, e.g. the value is minimum one character long

return value: boolean

inputIs.filled(''); // false
inputIs.filled('1'); // true

float

This function validates if a form input is a valid float (not type number)

return value: boolean

inputIs.float('1'); // false
inputIs.float('1.0'); // true

integer

This function validates if a form input is a valid integer (not type number)

return value: boolean

inputIs.integer('z'); // false
inputIs.integer('990'); // true

max

This function validates if a form input is maximum the length of target

return value: boolean

inputIs.max('value', 3); // false
inputIs.max('value', 5); // true

min

This function validates if a form input is minimum the length of a target

return value: boolean

inputIs.min('value', 6); // false
inputIs.('value', 3); // true

not

This function validates if a form input is not like the target

return value: boolean

inputIs.not('target', 'target'); // false
inputIs.not('value', 'target'); // true

number

This function validates if a form input is a valid number (not type number)

return value: boolean

inputIs.number('number'); // false
inputIs.number('1'); // true

partOf

This function validates if a form input is part of a provided characterset

return value: boolean

inputIs.partOf('z', 'part of ABC'); // false
inputIs.partOf('ABC', 'part of ABC'); // true

phonenumber

This function validates if a form input is a valid phonenumber

return value: boolean

inputIs.phonenumber('+12'); // false
inputIs.phonenumber('+1234567890'); // true

time

This function validates if a form input is a valid time

return value: boolean

inputIs.time('01:'); // false
inputIs.time('01:01'); // true

url

This function validates if a form input is a valid url

return value: boolean

inputIs.url('google.'); // false
inputIs.url('https://www.google.com'); // true

valid

This function validates form input to a regular expression

return value: boolean

inputIs.valid('google', /.at/); // false
inputIs.valid('hat', /.at/); // true

LICENSE

MIT © Lukas Aichbauer