Skip to content

CaseValidation

Checks if a string contains only alphabetic characters (A-Z, a-z).

  • The string to check.
  • True if only alphabetic characters, false otherwise.
Definition
function isAlpha(str: string): boolean
Examples
isAlpha('HelloWorld') // true
isAlpha('Hello123') // false

Checks if a string contains only alphanumeric characters (A-Z, a-z, 0-9).

  • The string to check.
  • True if only alphanumeric characters, false otherwise.
Definition
function isAlphaNumeric(str: string): boolean
Examples
isAlphaNumeric('Hello01') // true
isAlphaNumeric('1234567890') // false

Checks if a string is in snake_case format.

  • str1: string - The string to be checked.
  • alphanumeric: boolean - If true, allows numbers in the string.
  • True if the string is in snake_case format, false otherwise.
  • Use lowercase letters.
  • Separate words with underscores (_).
  • No numbers allowed, unless specified otherwise.
Definition
function isSnakeCase(str: string, alphanumeric = false): boolean
Examples
// Valid
isSnakeCase('snake_case_example') // true
isSnakeCase('hello_world') // true
// Valid with alphanumeric flag
isSnakeCase('with_1234', true) // true
isSnakeCase('pi_3_14', true) // true
// Invalid
isSnakeCase('123at_start') // false
isSnakeCase(' no_space_allowed') // false
isSnakeCase('no_CAPS') // false

Checks if a string is in kebab-case format.

  • str1: string - The string to be checked.
  • alphanumeric: boolean - If true, allows numbers in the string.
  • True if the string is in kebab-case format, false otherwise.
  • Use lowercase letters.
  • Separate words with hyphens (-).
  • No numbers allowed, unless specified otherwise.
Definition
function isKebabCase(str: string, alphanumeric = false): boolean
Examples
// Valid
isKebabCase('kebab-case-example') // true
isKebabCase('hello-world') // true
// Valid with alphanumeric flag
isKebabCase('with-1234', true) // true
isKebabCase('pi-3-14', true) // true
// Invalid
isKebabCase('123at-start') // false
isKebabCase(' no-space-allowed') // false
isKebabCase('no-CAPS') // false

Checks if a string is in camelCase format.

  • The string to be checked.
  • True if the string is in camelCase format, false otherwise.
  • Start with a lowercase letter.
  • Use uppercase for each new word.
  • Should consist of only letters.
  • No separator between words allowed.
  • No numbers allowed.
Definition
function isCamelCase(str: string): boolean
Examples
// Valid
isCamelCase('camelCaseExample') // true
isCamelCase('helloWorld') // true
// Invalid
isCamelCase('CAMEL') // false
isCamelCase(' noSpaceAllowed') // false
isCamelCase('withThe1234') // false

Checks if a string is in PascalCase format.

  • The string to be checked.
  • True if the string is in PascalCase format, false otherwise.
  • Start with an uppercase letter.
  • Use uppercase for each new word.
  • Should consist of only letters.
  • No separator between words allowed.
  • No numbers allowed.
Definition
function isPascalCase(str: string): boolean
Examples
// Valid
isPascalCase('PascalCaseExample') // true
isPascalCase('HelloWorld') // true
// Invalid
isPascalCase('PASCAL') // false
isPascalCase(' NoSpaceAllowed') // false
isPascalCase('WithThe1234') // false