CaseValidation
isAlpha
Section titled “isAlpha”Checks if a string contains only alphabetic characters (A-Z, a-z).
Parameter: string
Section titled “Parameter: string”- The string to check.
Returns: boolean
Section titled “Returns: boolean”- True if only alphabetic characters, false otherwise.
function isAlpha(str: string): boolean
isAlpha('HelloWorld') // trueisAlpha('Hello123') // false
isAlphaNumeric
Section titled “isAlphaNumeric”Checks if a string contains only alphanumeric characters (A-Z, a-z, 0-9).
Parameter: string
Section titled “Parameter: string”- The string to check.
Returns: boolean
Section titled “Returns: boolean”- True if only alphanumeric characters, false otherwise.
function isAlphaNumeric(str: string): boolean
isAlphaNumeric('Hello01') // trueisAlphaNumeric('1234567890') // false
isSnakeCase
Section titled “isSnakeCase”Checks if a string is in snake_case format.
Parameters
Section titled “Parameters”str1
:string
- The string to be checked.alphanumeric
:boolean
- If true, allows numbers in the string.
Returns: boolean
Section titled “Returns: boolean”- True if the string is in snake_case format, false otherwise.
Conventions
Section titled “Conventions”- Use lowercase letters.
- Separate words with underscores (
_
). - No numbers allowed, unless specified otherwise.
function isSnakeCase(str: string, alphanumeric = false): boolean
// ValidisSnakeCase('snake_case_example') // trueisSnakeCase('hello_world') // true
// Valid with alphanumeric flagisSnakeCase('with_1234', true) // trueisSnakeCase('pi_3_14', true) // true
// InvalidisSnakeCase('123at_start') // falseisSnakeCase(' no_space_allowed') // falseisSnakeCase('no_CAPS') // false
isKebabCase
Section titled “isKebabCase”Checks if a string is in kebab-case format.
Parameters
Section titled “Parameters”str1
:string
- The string to be checked.alphanumeric
:boolean
- If true, allows numbers in the string.
Returns: boolean
Section titled “Returns: boolean”- True if the string is in kebab-case format, false otherwise.
Conventions
Section titled “Conventions”- Use lowercase letters.
- Separate words with hyphens (
-
). - No numbers allowed, unless specified otherwise.
function isKebabCase(str: string, alphanumeric = false): boolean
// ValidisKebabCase('kebab-case-example') // trueisKebabCase('hello-world') // true
// Valid with alphanumeric flagisKebabCase('with-1234', true) // trueisKebabCase('pi-3-14', true) // true
// InvalidisKebabCase('123at-start') // falseisKebabCase(' no-space-allowed') // falseisKebabCase('no-CAPS') // false
isCamelCase
Section titled “isCamelCase”Checks if a string is in camelCase format.
Parameters: string
Section titled “Parameters: string”- The string to be checked.
Returns: boolean
Section titled “Returns: boolean”- True if the string is in camelCase format, false otherwise.
Conventions
Section titled “Conventions”- Start with a lowercase letter.
- Use uppercase for each new word.
- Should consist of only letters.
- No separator between words allowed.
- No numbers allowed.
function isCamelCase(str: string): boolean
// ValidisCamelCase('camelCaseExample') // trueisCamelCase('helloWorld') // true
// InvalidisCamelCase('CAMEL') // falseisCamelCase(' noSpaceAllowed') // falseisCamelCase('withThe1234') // false
isPascalCase
Section titled “isPascalCase”Checks if a string is in PascalCase format.
Parameters: string
Section titled “Parameters: string”- The string to be checked.
Returns: boolean
Section titled “Returns: boolean”- True if the string is in PascalCase format, false otherwise.
Conventions
Section titled “Conventions”- Start with an uppercase letter.
- Use uppercase for each new word.
- Should consist of only letters.
- No separator between words allowed.
- No numbers allowed.
function isPascalCase(str: string): boolean
// ValidisPascalCase('PascalCaseExample') // trueisPascalCase('HelloWorld') // true
// InvalidisPascalCase('PASCAL') // falseisPascalCase(' NoSpaceAllowed') // falseisPascalCase('WithThe1234') // false