17 lines
526 B
JavaScript
17 lines
526 B
JavaScript
|
|
/**
|
|
* Checks if the handle is valid.
|
|
* @param {string} handle - The handle to be validated.
|
|
* @returns {boolean} - Returns true if the handle is valid, otherwise returns false.
|
|
*/
|
|
export function isValidHandle(handle) {
|
|
// Length must be between 3 and 32 characters
|
|
if (handle.length < 3 || handle.length > 32) {
|
|
return false;
|
|
}
|
|
|
|
// Uses regular expression to validate if the handle consists of 26 letters (case-insensitive), underscores, and digits.
|
|
const regex = /^[a-zA-Z0-9_]+$/;
|
|
return regex.test(handle);
|
|
}
|