fix(core): Allow strings starting with numbers in alphanumeric string validator (#15425)

This commit is contained in:
Yiorgis Gozadinos
2025-05-16 09:38:21 +02:00
committed by GitHub
parent ec63a61652
commit 64b3fa3d17
2 changed files with 34 additions and 0 deletions

View File

@@ -35,6 +35,8 @@ export const tryToParseString = (value: unknown): string => {
};
export const tryToParseAlphanumericString = (value: unknown): string => {
const parsed = tryToParseString(value);
// We do not allow special characters, only letters, numbers and underscore
// Numbers not allowed as the first character
const regex = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
if (!regex.test(parsed)) {
throw new ApplicationError('Value is not a valid alphanumeric string', { extra: { value } });