Getting started
Validation
Validation Utility Functions
This section provides details on utility functions designed to validate data such as email, username, password and others. Most of these functions uses predefined regular expressions for their validation logic.
isValidEmail
isValidEmail(email: string): boolean
Parameters
email: string - The email address to validate.
Returns
boolean - Returnstrue if the email is valid,false otherwise.
Example usage
index.ts
import { isValidEmail } from '@6nehemie/textguard';
const isEmailValid = isValidEmail('example@example.com');
console.log(isEmailValid); // Output should be true or false
isValidUsername
isValidUsername(username: string): boolean
Parameters
username: string - The username to validate.
Returns
boolean - Returnstrue - The username to validate.false otherwise.
Example usage
index.ts
import { isValidUrsername } from '@6nehemie/textguard';
const isUsernameValid = isValidUsername('john_doe');
console.log(isUsernameValid); // Output should be true or false
isValidPassword
isValidPassword(password: string): boolean
Parameters
password: string - The password to validate.
Returns
boolean - Returnstrue - if the password is valid,false otherwise.
Example usage
index.ts
import { isValidPassword } from '@6nehemie/textguard';;
const isPasswordValid = isValidPassword('Pa$$w0rd!');
console.log(isPasswordValid); // Output should be true or false
arePasswordsMatching
arePasswordsMatching(password: string, confirmPassword: string): boolean
Parameters
password: string - The first password.
confirmPassword: string - The second password for confirmation.
Returns
boolean - Returnstrue if the passwords match,false otherwise.
Example usage
index.ts
import { arePasswordsMatching } from '@6nehemie/textguard';
const doPasswordsMatch = arePasswordsMatching('Pa$$w0rd!', 'Pa$$w0rd!');
console.log(doPasswordsMatch); // Output should be true or false