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 🙏

© 2024 – Pkg Stats / Ryan Hefner

validationfunction

v1.0.7

Published

To validate the input fields

Downloads

16

Readme

Validation Function

Validation function - A simple and effective input field validation which can validate Name, DOB, Age, Email, SSN, Phone number and Income.

Installation

npm i validationfunction

Usage

Simply add import validationfunction from 'validationfunction';

Name field validation

let Name = "James";
let Minlength= 4;
let isValidName = validationfunction.name(Name,Minlength);
/* validationfunction.name(Name,Minlength) will check for special characters and numbers and also will check the length of the name should be greater than the minlength parameter and returns 1 if the name is valid else returns 0 */

Date of Birth validation

let DOB = "10/10/2010";//"mm-dd-yyyy or mm/dd/yyyy"
let isValidDOB = validationfunction.dob(DOB);
/* validationfunction.dob(DOB) will check for future date and returns 1 if the DOB is a past date else returns 0 */

Age validation

let DOB = "10/10/2010";//"mm-dd-yyyy or mm/dd/yyyy"
let Age = 8;
let isValidAge = validationfunction.age(DOB,Age);
/* validationfunction.age(DOB,Age) will check the DOB with Age and returns 1 if the age is valid else returns 0 */

Email validation

let Email = "[email protected]";
let EmailEndswith ='@gmail.com';
let isValidEmail = validationfunction.email(Email,EmailEndswith);
/* validationfunction.email(Email,EmailEndswith) its contain 2 params here first param is mandatory it will check for the email valid format and will returns 1 if the Email ID is valid else returns 0, if the user provides second params EmailEndswith then it will check whether the Email ending with the EmailEndswith params if the condition satisfied it will return 1 else returns 0. */

Work Email validation

let Email = "[email protected]";
let isValidEmail = validationfunction.workmail(Email);
/*
 validationfunction.workmail(Email) will check for a valid Email(other than free mails(gmail,yahoo,..etc)) and returns 1 if the Email ID is valid else returns 0 */

Phone validation

let Phone = "9876543210";
let isValidPhone = validationfunction.phone(Phone);
/* validationfunction.phone(Phone) will check for a valid Phone number and returns 1 if the Phone number is valid else returns 0 */

SSN validation

let SSN = "876543210";//"876-54-3210 or 876543210"
let isValidSSN = validationfunction.ssn(SSN);
//Invalid SSN format
/*
Any number beginning with "000", "666", "900-999"
Any number has a middle "00", or ends in "0000" will never be a valid SSN.
*/
/* validationfunction.ssn(SSN) will check for a valid SSN and returns 1 if the SSN is valid else returns 0 */

Income validation

let Income = "10000.00";
let noOfDecimals = "2";
let isValidIncome = validationfunction.income(Income, noOfDecimals);
/* validationfunction.income(Income, noOfDecimals) will check for the provided income with the number of allowed decimals and returns 1 if the Income(with specified decimals) is valid else returns 0 */