mirror of
https://github.com/formbricks/formbricks.git
synced 2026-03-06 18:39:28 -06:00
14 lines
436 B
TypeScript
14 lines
436 B
TypeScript
/**
|
|
* Validates that a string is a safe identifier.
|
|
* Safe identifiers can only contain lowercase letters, numbers, and underscores.
|
|
* They cannot start with a number.
|
|
*/
|
|
export const isSafeIdentifier = (value: string): boolean => {
|
|
// Must start with a lowercase letter
|
|
if (!/^[a-z]/.test(value)) {
|
|
return false;
|
|
}
|
|
// Can only contain lowercase letters, numbers, and underscores
|
|
return /^[a-z0-9_]+$/.test(value);
|
|
};
|