Skip to content

Commit ad655de

Browse files
committed
Ajustes gerais
1 parent 6942b81 commit ad655de

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/sanitializators/Sanitizer.Replace.pas

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,37 @@ TSanitizerReplace = class(TDataValidatorItemBaseSanitizer)
4343
private
4444
FOldValue: string;
4545
FNewValue: string;
46+
FIgnoreCase: Boolean;
4647
public
4748
function Sanitize: TValue; override;
48-
constructor Create(const AOldValue: string; const ANewValue: string);
49+
constructor Create(const AOldValue: string; const ANewValue: string; const AIgnoreCase: Boolean = True);
4950
end;
5051

5152
implementation
5253

5354
{ TSanitizerReplace }
5455

55-
constructor TSanitizerReplace.Create(const AOldValue: string; const ANewValue: string);
56+
constructor TSanitizerReplace.Create(const AOldValue: string; const ANewValue: string; const AIgnoreCase: Boolean = True);
5657
begin
5758
inherited Create;
5859
FOldValue := AOldValue;
5960
FNewValue := ANewValue;
61+
FIgnoreCase := AIgnoreCase;
6062
end;
6163

6264
function TSanitizerReplace.Sanitize: TValue;
6365
var
6466
LValue: string;
67+
LFlags: TReplaceFlags;
6568
begin
6669
LValue := GetValueAsString;
6770

68-
LValue := StringReplace(LValue, FOldValue, FNewValue, [rfReplaceAll]);
71+
if FIgnoreCase then
72+
LFlags := [rfReplaceAll, rfIgnoreCase]
73+
else
74+
LFlags := [rfReplaceAll];
75+
76+
LValue := StringReplace(LValue, FOldValue, FNewValue, LFlags);
6977

7078
SetValueAdapter(LValue);
7179

0 commit comments

Comments
 (0)