Improved dotEnv parse of boolean value. (yes,1,true,no,0,false)

This commit is contained in:
Daniele Teti 2024-09-13 09:48:12 +02:00
parent 5c3c0565e8
commit 595fa907e6

View File

@ -346,7 +346,16 @@ begin
end
else
begin
if not TryStrToBool(lTmp.Trim, Result) then
lTmp := lTmp.Trim.ToLower;
if (lTmp = 'yes') or (lTmp='1') or (lTmp='true') then
begin
Exit(True);
end;
if (lTmp = 'no') or (lTmp='0') or (lTmp='false') then
begin
Exit(False);
end;
if not TryStrToBool(lTmp, Result) then
begin
raise EMVCDotEnv.CreateFmt('Env "%s" is not a valid boolean [Current Value: "%s"]', [Name, lTmp]);
end;