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.
This commit is contained in:
YOMAN1792
2025-05-08 14:18:57 -04:00
committed by GitHub
parent 099bd7dd46
commit dc512f97d2
+6 -1
View File
@@ -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