valiend
v1.2.1
Published
a package for validate and check auth input
Downloads
129
Maintainers
Readme
Valiend
Valiend is an open source package created to make checking email, password and phone number input easier. By using this package, you can check these inputs much more easily than before and develop different conditions in your project according to them.
install
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
$ npm install valiend
Usage
To use valiend, you must call it according to your use of common js or es module
Common JS
const valiend = require('valiend'); //common js
valiend.isEmail('[email protected]');
ES Module
import {isEmail} from 'valiend'; //ES Module
isEmail('[email protected]');
Features
check validate email
valiend.isEmail('[email protected]'); //true
check validate Phone number
valiend.isPhoneNumber('+989121234567'); //true
valiend.isPhoneNumber('09121234567',['fa-IR']); //true
check validate Postal Code
valiend.isPostalCode('12345-12345'); //true
valiend.isPostalCode('12345-12345',['fa-IR','de-DE']); //true
check validate VAT number
valiend.isVAT('DE494050532',['de-DE']); //true
Check the contents of the password
valiend.passwordContains('Test4:@5tARian');
/*{
isHaveCapitalLetter: true,
isHaveSmallLetter: true,
isHaveNumber: true,
isHaveCharacter: true,
passwordLength: 14,
capitalLetterCount: 3,
smallLetterCount: 7,
numberCount: 2,
characterCount: 2
}*/
Separate different parts of the email
valiend.separateEmail("[email protected]");
/*{
emailUsername: 'aeromche',
emailSymbol: '@',
emailMailServer: 'gmail',
emailMailServerUrl: 'gmail.com',
emailDomain: '.com'
}*/
Create a random password
valiend.passwordGenerator(12); //r_YXST46!a7e
Check password quality
valiend.passwordQuality('Honh3443') //75
Check for numeric value
valiend.isNumeric("1237653423") //true
valiend.isNumeric("12376e423") //false
Checking whether the input value is within the range
valiend.isInRange(32,{minRange : 18,maxRange : 90}) //true
Checking the validity of a user name in terms of the characters used
valiend.isUsername("ariankoochak") //true
valiend.isUsername("_.aeromche._",{validChars : ['@','_','$','#','.']}) //true
valiend.isUsername("@eromche") //false
valiend.isUsername("@eromche$_") //false
Checking the security and strength of the password
valiend.isSafePassword("A5h#3232") //true
valiend.isSafePassword("aadfdf") //false
valiend.isSafePassword("SA23sa#$",{strictMode : true}) //true
valiend.isSafePassword("A5h#3232",{strictMode : true}) //false
Creating a random otp (one time password) numerically
valiend.getOtpCode() //85943
valiend.getOtpCode({otpLength : 7}) //0856473
Validate all data together
inputs = {
username: "@riankoc",
password: "aeromch@e3",
email: "[email protected]",
};
const schema = valiend.schemaMaker({
usernameSchema: {
validChars: ["_"],
},
passwordSchema: {
safePassword: true,
},
});
valiend.valiendCheck(inputs, schema)
/*
{
result: false,
errors: [{username : "username not valid"},{ password: "password is not safe" }],
}
*/
inputs = {
username: "@riankoc",
password: "aeromch@e3",
email: "[email protected]",
};
const schema = valiend.schemaMaker({
usernameSchema: {
validChars: ["_"],
},
passwordSchema: {
safePassword: true,
},
});
valiend.valiendCheck(inputs, schema)
/*
{
result: false,
errors: [{username : "username not valid"},{ password: "password is not safe" }],
}
*/