/string-regex-checker

A variety of regex functions that check against strings. For both JavaScript and TypeScript.

Primary LanguageTypeScript

String Validation Functions

This repository contains JavaScript functions for validating various types of strings. Each function takes a string as input and returns true if the string is valid, and false otherwise.

List of Functions

  1. containsOnlyLetters(str): Checks if a string contains only letters (uppercase and lowercase)
  2. isValidEmail(email): Checks if a string is a valid email address
  3. isValidUrl(url): Checks if a string is a valid URL
  4. containsOnlyNumbers(str): Checks if a string contains only numbers
  5. isValidPhoneNumber(phoneNumber): Checks if a string is a valid phone number
  6. containsOnlyAlphanumeric(str): Checks if a string contains only alphanumeric characters
  7. isValidUsername(username): Checks if a string is a valid username (3-16 characters, letters and numbers only)
  8. isValidPassword(password): Checks if a string is a valid password (8-20 characters, at least one uppercase letter, one lowercase letter, and one number)
  9. isValidCreditCardNumber(creditCardNumber): Checks if a string is a valid credit card number (Visa, MasterCard, American Express, and Discover)
  10. isValidDate(date): Checks if a string is a valid date in the format YYYY-MM-DD
  11. isValidTime(time): Checks if a string is a valid time in the format HH:MM:SS
  12. isValidZipCode(zipCode): Checks if a string is a valid US zip code (5 digits)
  13. isValidStateAbbreviation(stateAbbreviation): Checks if a string is a valid US state abbreviation (2 uppercase letters)
  14. isValidIPv4Address(ipv4Address): Checks if a string is a valid IPv4 address
  15. isValidIPv6Address(ipv6Address): Checks if a string is a valid IPv6 address
  16. isValidMacAddress(macAddress): Checks if a string is a valid MAC address
  17. isValidHexColorCode(hexColorCode): Checks if a string is a valid hexadecimal color code (e.g. #FFFFFF or #000000)
  18. isValidRgbColorCode(rgbColorCode): Checks if a string is a valid RGB color code (e.g. rgb(255,255,255))
  19. isValidCssColorCode(cssColorCode): Checks if a string is a valid CSS color code (e.g. red, #FFFFFF, rgb(255,255,255))
  20. isValidSlug(slug): Checks if a string is a valid slug (lowercase letters, numbers, and hyphens only)
  21. isValidUuid(uuid): Checks if a string is a valid UUID (version 1, 3, 4, or 5)