mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user