Skip to content

Commit

Permalink
Improved dotEnv parse of boolean value. (yes,1,true,no,0,false)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed Sep 13, 2024
1 parent 5c3c056 commit 595fa90
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sources/MVCFramework.DotEnv.pas
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,16 @@ function TMVCDotEnv.Env(const Name: string;
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;
Expand Down

0 comments on commit 595fa90

Please sign in to comment.