Skip to content

Commit

Permalink
Urlmapped boolean parameters accepts: true/false, yes/no, 1/0 as trut…
Browse files Browse the repository at this point in the history
…hy and falsy values
  • Loading branch information
danieleteti committed Jun 19, 2024
1 parent a44b26c commit f795327
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions sources/MVCFramework.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3405,14 +3405,18 @@ function TMVCEngine.GetActualParam(const AFormalParam: TRttiParameter;
begin
if AFormalParam.ParamType.QualifiedName = 'System.Boolean' then
begin
if SameText(AStringValue, 'true') or SameText(AStringValue, '1') then
Result := True
else if SameText(AStringValue, 'false') or SameText(AStringValue, '0') then
Result := False
if SameText(AStringValue, 'true') or SameText(AStringValue, '1') or SameText(AStringValue, 'yes') then
begin
Result := True;
end
else if SameText(AStringValue, 'false') or SameText(AStringValue, '0') or SameText(AStringValue, 'no') then
begin
Result := False;
end
else
begin
raise EMVCException.CreateFmt(http_status.BadRequest,
'Invalid boolean value for parameter %s. Boolean parameters accepts only "true"/"false" or "1"/"0".',
'Invalid boolean value for parameter %s. Boolean parameters accepts only "true"/"false", "yes"/"no" or "1"/"0".',
[AFormalParam.name]);
end;
end
Expand Down

0 comments on commit f795327

Please sign in to comment.