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

validify-string

v2.3.0

Published

Ensure accurate and secure input with our reliable string validation library.

Downloads

17

Readme

validify-string

Ensure accurate and secure input with our reliable string validation library.

Install

npm i validify-string

Example

import validator from "validify-string";

validator.isPasswordStrong("StrongPass12@#");
validator.isAlpha("Jagroop");

const user = {
    "Username": "YS",
    "Role": "Admin",
    "Email": "[email protected]"
}
const jwt = validator.generateJWT(user, secret);
console.log(validator.decodeJWT(jwt).payload);

Details

validator.isEmpty(str)
This function will check if string is empty or not.
validator.isIdentical(strOne , strTwo)
This function will check if string One is equal to string Two.
validator.isAlpha(str)
This function will check if string contain Alphabets only.
validator.isAlphaNumeric(str)
This function will check if string is AlphaNumeric string only.
validator.isValidEmail(email)
This function will check if given Input is valid email or not.
validator.countWords(str)
This function will return number of words in a string.
validator.isAvailable(str, word)
This function will check if given word is available in the string or not.
validator.countOccurrences(str, word)
This function will count the occurrence of word in the string.
validator.isPasswordStrong(password)
This function will check if given Input is valid password or not.
validator.isURL(str)
This function will check if given Input is valid URL or not.
validator.isUpperCase(str)
Check if the entire string is in uppercase.
validator.isLowerCase(str)
Check if the entire string is in lowercase.
validator.isDate(str)
Check if the string represents a valid date.
validator.isPalindrome(str)
Check if the string is a palindrome.
validator.isValidPhone(phoneNumber)
This function will check if given phoneNumber (of type string) is valid Phone number or not.
validator.isValidCardNumber(cardNumber)
This function will check if given Card number (of type string) is valid Card Number or not by using Luhn's Algorithm.
validator.isIP(IP Address)
This function will check if string contains a Valid IP address or not.
validator.isAlphanumeric(str)
This function will check if string is alphanumeric or not.
validator.isHash(str)
This function will check if string is a hash or not.
validator.isHexadecimal(str)
This function will check if string is hexadecimal or not.

validator.isBase32(str)
This function will check if string isBase32 or not.
validator.isBase64(str)
This function will check if string isBase64 or not.
validator.isEthereumAddress(str)
This function will check if string isEthereumAddress or not.
validator.isASCII(str)
This function will check if each character of string is in ASCII Value or not.
validator.isStringAContainsB(StringA, StringB)
This function checks if the string A contains the string B
validator.isStringAMatchesB(StringA, StringB)
This function checks if the string A matches the string B
validator.isHexColor
utility function is designed to check whether a given string represents a valid hexadecimal color code
validator.isJSON
utility function is used to check whether a given string is a valid JSON (JavaScript Object Notation) string
validator.isJWT
utility function is used to check whether a given string is a valid JSON Web Token (JWT)
validator.isStringWithoutSpecialCharacters(str)
This function will check the string is Without Special Characters or not. 
validator.startsWithPrefix(str)
This function will Check if a string starts with a specific prefix or not. 
validator.endsWithSuffix(str)
This function will Check if a string end with a specific suffix or not. 
validator.getAlphaNumString(str)
This function returns a random alphanumeric string of length n.
validator.getLeftSubstring(str, int)
This function returns the substring denoted by n positive left-most characters.
validator.encrypt(str)
This function will encrypt the string to a base64 format.
validator.decrypt(str)
This function will decrypt the base64 string to the original string.
validator.generateJWT(payload, secret, expiresInSec)
This function will generate a JSON Web Token (JWT) with the given payload and expiration time using the HMAC SHA256 algorithm.
validator.decodeJWT(token)
This function will decode the given JSON Web Token (JWT) and return the payload.
validator.addUnderscore(str)
This function replace the space to underscore from the string.
validator.removeSpace(str)
This function remove the space from the string .
validator.removeUnderscore(str)
This function remove the underscore from the string . 
validator.removeNumber(str)
This function remove the number from string.
validator.addFullstop(str)
This function replaces space in string with fullstop.
validator.generateRandomString(length)
This function generates the random string of given length.

Contributing Guidelines

Please go through the guidelines below to make your first contribution:

Issues

  • Always create an issue before creating a pull request.
  • Always ensure that there is no other open issue similar to the one that you want to create.
  • Always start working on an issue after getting assigned to it.

Creating a Pull Request

  • Fork the repository

  • Clone the forked repository to your local machine:

    git clone https://github.com/<github-username>/validify-string.git
  • Navigate to the project directory:

    cd validify-string
  • Install all dependencies:

    npm install
  • Create and switch to a new branch:

    git switch -c <branch>
  • Launch the application:

    npm run build
  • Make changes to the project and stage them:

    git add .
  • Commit the changes:

    git commit -m "<message>"
  • Push the changes to the correponding remote branch:

    git push origin <branch>
  • Create a pull request!