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

validoz

v1.1.5

Published

Validoz is both Client side and Server side form validator.

Downloads

19

Readme

Validoz

Validoz is both Client side and Server side form field validator.

Installation

$ npm install validoz
Or Download

Sample code

let {validoz, isValid} = require('validoz');
let fields = [
    {
        name: "Full name",
        type: "fullname",
        value: 'John doe'
    },
    {
        name: "Email address",
        type: "email",
        value: '[email protected]'
    },
    {
        name: "Age",
        type: "number",
        value: 12,
        min: 18,
    }
]
let result = validoz(fields);
console.log(result); 
/* 
result: 
[
    { field: 'Full name', message: '' },
    { field: 'Email address', message: '' },
    { field: 'Age', message: 'Age must be at least 18' }
] */
console.log(isValid(result)); // false

Whenever a field message value be empty string ('') means no validation error. In the example above we put fields in array and all the fields message shoul be be emptry string '' to isValid() function returns true otherwise it returns false.

Single field example

Here is an example of single object field instead of array of objects.

let {validoz, isValid, isValidByName} = require('validoz');

let field = {
    name: "Full name",
    type: "fullname",
    value: 'John doe'
};

let result = validoz(field);
console.log(result); // { field: 'Full name', message: '' }
isValid(result); // true
isValidByName(result, 'Full name'); // true

Types

Here is the types of field.

| name | Description | | ------ | ------ | | text | Any characters | | password | String must contain at least one numberic, one upper case, one lower case characters and the length at least 6 characters | | fullname | String should contain at least 2 words with 3 characters for each of the words and separated by space. It can contain more than one word.| | username | Like Instagram username. | | word | Alphabet characters. | | number | An integer number | | date | Example 21/03/2020 string. | | time | Example 05:12 string. |

Options

| name | Description | | ------------- | ------ | | name | Field name | | value | Field value | | type | Field type | | required | Boolean. default: true | | min and max | Minumum and Maximum of type number. Each of them can be passed alone. | | minDigits and maxDigits | Minumum and Maximum digits of type number. Each of them can be passed alone. | | minLength and maxLength | Minimum and Maximum length of the string types. | | dateFormat | String values of mm/dd/yyyy, mm-dd-yyyy, dd/mm/yyyy, dd-mm-yyyy, yyyy/mm/dd and yyyy-mm-dd | | equal | A field value and equal value to be equal. | | notEqual | A field value and equal value not to be equal. |

Date example

let {validoz, isValid, isValidByName} = require('validoz');

let field = {
    name: "Date",
    type: "date",
    value: '24/05/2020',
    dateFormat: 'dd/mm/yyyy',
    startDate: '08/02/2020',
    endDate: '24/05/2020',
};

let result = validoz(field);
console.log(result); // { field: 'Date', message: '' }
isValid(result); // true
isValidByName(result, 'Date'); // true

Other example

let {validoz, isValid, isValidByName} = require('validoz');

let {field} = require('./form.js');
let result = validoz(field);
console.log(result); 
/*
Returns: 
[
  { field: 'Full name', message: '' },
  { field: 'Email address', message: 'Email address is invalid' },
  { field: 'Age', message: 'Age must be between 18 and 60' },
  { field: 'Best friend', message: 'Best friend value is wrong' },
  {
    field: 'Password',
    message: 'Password must contain at least one numberic, one upper case, one lower case characters and the length at least 6 characters'
  }
]
*/
isValid(result); // false
isValid(result); // false
isValid(result[0]); // "Full name", true
isValidByName(result, 'Full name'); // true
isValidByName(result, 'Email address'); // false
isValidByName(result, 'Password'); // false
// form.js file
export let field = [
    {
        name: "Full name",
        type: "text",
        value: 'Hello world',
        minLength: 6
    },
    {
        name: "Email address",
        type: "email",
        value: '[email protected]'
    },
    {
        name: "Age",
        type: "number",
        value: 12,
        min: 18,
        max: 60,
    },
    {
        name: "Best friend",
        type: "text",
        value: 'Doe',
        equal: 'John' // value must be John
    },
    {
        name: "Password",
        type: "password", // you can also pass text if you don't want regex pattern to be conditioned
        value: '123456',
        minLength: 6,
        maxLength: 30,
    }
];

Author

Kamyar Lajani

License

MIT