4.0.1 • Published 1 year ago

validplease v4.0.1

Weekly downloads
5
License
ISC
Repository
github
Last release
1 year ago

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('johndoe@gmail.com').required().isEmail();
console.log('output:', result);

// console result:
// output: ValidPlease {
//  input: 'johndoe@gmail.com',
//  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

npm.io npm.io npm.io npm.io npm.io

4.0.1

1 year ago

4.0.0

1 year ago

3.2.0

2 years ago

3.1.0

3 years ago

3.0.0

4 years ago

2.5.2

4 years ago

2.5.1

4 years ago

2.5.0

4 years ago

1.5.0

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.1

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago