Skip to content

CaseValidation

isAlpha

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

isAlpha('HelloWorld') // true
isAlpha('Hello123') // false

isAlphaNumeric

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

isAlphaNumeric('Hello01') // true
isAlphaNumeric('1234567890') // false

isSnakeCase

Checks if a string is in snake_case format.

// 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

isKebabCase

Checks if a string is in kebab-case format.

// 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

isCamelCase

Checks if a string is in camelCase format.

// Valid
isCamelCase('camelCaseExample') // true
isCamelCase('helloWorld') // true
// Invalid
isCamelCase('CAMEL') // false
isCamelCase(' noSpaceAllowed') // false
isCamelCase('withThe1234') // false

isPascalCase

Checks if a string is in PascalCase format.

// Valid
isPascalCase('PascalCaseExample') // true
isPascalCase('HelloWorld') // true
// Invalid
isPascalCase('PASCAL') // false
isPascalCase(' NoSpaceAllowed') // false
isPascalCase('WithThe1234') // false