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

validplease

v4.0.1

Published

A validator package with built-in Persian messages.

Downloads

101

Readme

validplease

A JS module for input validation with custom Persian message. Keep your eyes on new changes 🤩 in version 2.x (scroll down to see new methods) Thanks to rimadarji

New update for different language support


Now you can select output messages in different languages ( 'en' for English, 'fa': for Persian, and more coming soon!) on initialize. Example:

const VP = require('validplease');
const vp = new VP(VP.language.en);

Warm Up


Why should i use validplease?

  • Local in IR-FA.
  • Zero dependency.
  • More than 110 unit tests. 100% methods coverage.
  • No data leakage in message.
  • Clean an clear Persian message.
  • Customizable.
  • Simple. You can simply jump into the code and make a pull for you changes.

I accept any contributes with open arms \./

Installation


npm i validplease

Usage


const VP = require('validplease');
const vp = new VP();

Samples


const result = vp.v('[email protected]').required().isEmail();
console.log('output:', result);

// console result:
// output: ValidPlease {
//  input: '[email protected]',
//  alias: null,
//  message: null,
//  success: true
// }
const result = vp.v('something that is not an email address').aliasName('آدرس ایمیل').required().isEmail();
console.log('output:', result);

// console result:
// output: ValidPlease {
//  message: 'پارامتر آدرس ایمیل را به صورت یک آدرس ایمیل صحیح وارد نمایید',
//  success: false
// }

Methods


.aliasName('Your alias name')
// The Alias name for this variable which is going to use in messages

.required()
// Checks variable must be set

.max(maximum number)
// Checks the input to be lower than maximum number

.min(minimum number)
// Checks the input to be greater than minimum number

.len(length)
// Checks the length of input to be equal with given length

.maxLen(maximum number)
// Checks the length of input to be lower than maximum number

.minLen(minimum number)
// Checks the length of input to be greater than maximum number

.isInt()
// Checks the input must be number

.isBoolean()
// Checks the input to be boolean (=== true|false)

.isEmail()
// Checks the input to be a valid email address

.isMobile()
// Checks the input to be a valid Iranian format mobile number (eg: 09123456789)

.isDate('separator eg:-')
// Checks the input to be valid date (eg: 1399-03-25)

.isMeliCode()
// Checks the input to be a valid Iranian national code format (Code Meli)

.isPostalCode()
// Checks if is a valid postal code

.isPhone()
// Checks if is a valid phone number

.isPersian()
// Checks if a valid Persian language character detected

.isEnglish()
// Checks if all characters are in English language

.isPersianDigit()
// Checks if all characters are in Persian language digit

.isEnglishDigit()
// Checks if all characters are in English language digit

.isIP()
// Checks the input to be a valid IP address in v4 format

.isIPv6()
// Checks the input to be a valid IP address in v6 format

.isVersion()
// Checks the input if it's a valid software version with maximum 4 scopes (major.minor.patch.build eg: 1.2 | 1.2.3 | 1.2.3.4)

.isIn(your array)
// Checks is in array

.pattern('Given pattern')
// Checks given pattern on the input