TypeScript icon, indicating that this package has built-in type declarations

0.5.2 • Public • Published


A tiny js library for Form validation.

Node Version License Min Size codecov build semantic-release code style: prettier


npm install verifierjs --save
yarn add verifierjs


import { Verifier, anyone } from 'verifierjs';
// CommonJS
const {Verifier, anyone} = require('verifierjs');
<!-- Vanilla JS -->
<!-- Minified Version-->
<script src=""></script>
<!-- UnMinified Version-->
<script src=""></script>
	const { Verifier, anyone } = verifierjs;


Color conversion functions are transferred to color-converter


// isUsername
new Verifier('username').isUsername().correct// returns true
new Verifier('$username').isUsername().correct// returns false
new Verifier('username').isUsername(/\w{4,}/).correct// returns true
new Verifier('username').isUsername({length: /\w{4,}/}).details// returns {lenght:true}

// isPassword
new Verifier('secret').isPassword().correct // returns false
new Verifier('secreT@123').isPassword().correct // returns true
new Verifier('secret').isPassword(/.{1,}/).correct // returns true
new Verifier('secret').isPassword({length: /.{1,}/}).details // returns{lenght:true}

// isEmail
new Verifier('').isEmail().correct // returns false
new Verifier('').isEmail().correct// returns true

// isLengthen
new Verifier('exact').isLengthen(5).correct // returns true
new Verifier('greaterthan').isLengthen('gt10').correct // returns true
new Verifier('lowerthan').isLengthen('lt10').correct // returns true

// excludes
new Verifier("hello").excludes("bye").correct //returns true
new Verifier("hello").excludes(anyone("bye")).correct //returns false
new Verifier("hey!hello").excludes("hello").details.excludes //returns false

// includes
new Verifier("hello").includes("bye").correct //returns false
new Verifier("hello").includes(anyone("bye")).correct //returns true
new Verifier("hey!hello").includes("hello").details.includes //returns true

// startsWith
new Verifier("Hey Buddy").startsWith("Hey").correct // return true
new Verifier("Hey Buddy").startsWith("hehe").correct // return false
new Verifier("Hey Buddy").startsWith(anyone("Hey")).details.startsWith // return true
new Verifier("Hey Buddy").startsWith(/[hello]/i).details.startsWith // return true

// endsWith
new Verifier("Hey Buddy").endsWith("uddy").correct // return true
new Verifier("Hey Buddy").endsWith("hehe").correct // return false
new Verifier("Hey Buddy").endsWith(anyone("Hey")).details.endsWith // return true
new Verifier("Hey Buddy").endsWith(/[hello]$/i).details.endsWith // return false

// isLink
new Verifier('').isLink().correct // returns true
new Verifier('').isLink().correct // returns true
new Verifier('').isLink(/^(http|https)/) // returns true
new Verifier('').isLink() // returns false

// consistOf
new Verifier("helloG").consistOf({
    uppercaseAlpha: true,
    lowercaseAlpha: true
}).correct //returns true
new Verifier("hello_G").consistOf({
    uppercaseAlpha: true,
    lowercaseAlpha: true,
    custom: "_-"
}).correct //returns true
new Verifier("hello_G").consistOf({
    uppercaseAlpha: true,
    lowercaseAlpha: true,
}).correct //returns false

// ageCalc
new Verifier('2005-02-22').ageCalc() //  16
new Verifier('WrongFormat').ageCalc() //  Error Verifier.ageCalc:Invalid Date

// array - Can be use on any chaineble method
new Verifier('hello').isLengthen(5).array() //  returns [[length],[true]]
new Verifier('username').isUsername().isLengthen("gt4 lt30").array() // returns[["start", "syntax", "length"],[true, true, true]]

Verifier Class Properties

    correct: true If all the validation is successful,
    details: detail version of `correct`,
    ... All methods

Username Default syntax

  • Username must start with alphabetic characters
  • Username should only contain letters, numbers,underscores,dashes,dots

Password Default syntax

  • must contain at least one lowercase letter
  • must contain at least one uppercase letter
  • must contain at least one symbol or number
  • length must be at least 8 characters long


  • DOB Format : YY-MM-DD

Chainable Functions

  1. isUsername
  2. isPassword
  3. isEmail
  4. isLengthen
  5. includes
  6. excludes
  7. startsWith
  8. endsWith
  9. isLink
  10. consistOf

Non Chainable Methods

  1. array : returns array in which first element is array of properties(validation) names and second element is array of properties(validation) values
  2. ageCalc : Calculates Age

Helper Function

  1. anyone:
 new Verifier("HeyThere").includes(anyone("hello")).correct // return true
  • What it basically does is that it tells the includes function that if string(which is to verify) contains "h" or "e" or "l" or "o" if anyone of them does then just check if remaining functions in the chain are passed if they had then just set correct to true

  • Same goes for excludes func check if "h" or "e" or "l" or "o" is present in the string if anyone of them does then just set correct to false



Bugs and Issues

If you encounter any bugs or issues, feel free to open an issue at github or email me to I also always like to hear from you, if you’re using my code.

Package Sidebar


npm i verifierjs

Weekly Downloads






Unpacked Size

124 kB

Total Files


Last publish


  • vakharia_heet