ts-validation-helpers
v1.0.3
Published
Validation for modile number, email and password in typescript
Downloads
18
Maintainers
Readme
Validation Package
This package provides functions for validating mobile numbers, email addresses, and passwords.
Installation
You can install this package via npm:
npm install ts-validation-helpers
import { validateMobileNumberString, validateMobileNumberInt, validateEmail, validatePassword } from 'ts-validation-helpers';
// Mobile number validation (string version)
const mobileNumberString = "1234567890";
const mobileNumberValidationResultString = validateMobileNumberString(mobileNumberString) ? 'Pass' : 'Fail';
console.log(`Mobile Number Validation Result (String): ${mobileNumberValidationResultString}`);
// Mobile number validation (number version)
const mobileNumberNumber = 1234567890;
const mobileNumberValidationResultNumber = validateMobileNumberInt(mobileNumberNumber) ? 'Pass' : 'Fail';
console.log(`Mobile Number Validation Result (Number): ${mobileNumberValidationResultNumber}`);
// Email validation
const email = "[email protected]";
const emailValidationResult = validateEmail(email) ? 'Pass' : 'Fail';
console.log(`Email Validation Result: ${emailValidationResult}`);
// Password validation
const password = "Password123#";
const structure = "ULDS"; // U for uppercase, L for lowercase, D for digit, S for special character
const minLength = 8;
const passwordValidationResult = validatePassword(password, structure, minLength) ? 'Pass' : 'Fail';
console.log(`Password Validation Result: ${passwordValidationResult}`);