From dc512f97d29da782449dc1d4d88e6d4fbdf8a4b2 Mon Sep 17 00:00:00 2001 From: YOMAN1792 <94007829+YOMAN1792@users.noreply.github.com> Date: Thu, 8 May 2025 14:18:57 -0400 Subject: [PATCH] feat(functions.lua): add optional digit support to IsValidLocaleString Modified the ESX.IsValidLocaleString function to accept an optional `allowDigits` parameter. When true, the function now allows numerical characters (0-9) in addition to the configured character ranges. This improves string validation flexibility across locales. --- [core]/es_extended/shared/functions.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/[core]/es_extended/shared/functions.lua b/[core]/es_extended/shared/functions.lua index 32c7ea33..8e326150 100644 --- a/[core]/es_extended/shared/functions.lua +++ b/[core]/es_extended/shared/functions.lua @@ -212,8 +212,9 @@ function ESX.Await(conditionFunc, errorMessage, timeoutMs) end ---@param str string +---@param allowDigits boolean? Allow numbers if necessary ---@return boolean -function ESX.IsValidLocaleString(str) +function ESX.IsValidLocaleString(str, allowDigits) if not ESX.ValidateType(str, 'string') then return false end @@ -228,6 +229,10 @@ function ESX.IsValidLocaleString(str) {0x00C0, 0x02AF} -- Latin Extended } + if allowDigits then + defaultRanges[#defaultRanges + 1] = {0x0030, 0x0039} -- 0-9 Numbers + end + local localeRanges = { ["el"] = { {0x0370, 0x03FF} }, -- Greek ["sr"] ={ {0x0400, 0x04FF} }, -- Cyrillic