Skip to main content

Function: alphanumeric()

alphanumeric(errorMessage?): Validator<string, string, string>

Defined in: validation/validators/index.ts:173

Validates string contains only alphanumeric characters.

Parameters

errorMessage?

string

Custom error message (optional)

Returns

Validator<string, string, string>

Validator that checks alphanumeric characters

Example

alphanumeric()('John123') // => Valid('John123')
alphanumeric()('John@123') // => Invalid(['Must contain only letters and numbers'])