Skip to content

Commit 45b2844

Browse files
committed
Ajustes gerais
* Ajuste na validação IsOptional - Se for True, ele não continua a validação daquele validate específico * Se o valor do JSON for null. ele entende como vazio.
1 parent 60e1a52 commit 45b2844

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/core/DataValidator.ItemBase.pas

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,15 @@ function TDataValidatorItemBase.GetValueAsString: string;
155155

156156
if Assigned(LJSONPair) then
157157
begin
158-
LValue := LJSONPair.JsonValue.ToString.Trim(['"']);
159-
Result := StringReplace(LValue, '\/', '/', [rfReplaceAll]);
158+
if LJSONPair.JsonValue is TJSONNull then
159+
begin
160+
Result := LValue;
161+
end
162+
else
163+
begin
164+
LValue := LJSONPair.JsonValue.ToString.Trim(['"']);
165+
Result := StringReplace(LValue, '\/', '/', [rfReplaceAll]);
166+
end;
160167
end;
161168
end
162169
else

src/validators/Validator.IsOptional.pas

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,12 @@ function TValidatorIsOptional.Check: IDataValidatorResult;
6262
var
6363
LValue: string;
6464
R: Boolean;
65-
LIsOptional: Boolean;
6665
begin
6766
LValue := GetValueAsString;
68-
R := False;
69-
LIsOptional := True;
7067

7168
if Assigned(FOptionalExecute) then
72-
LIsOptional := FOptionalExecute(LValue);
73-
74-
if LIsOptional then
69+
R := FOptionalExecute(LValue)
70+
else
7571
R := LValue.IsEmpty;
7672

7773
if FIsNot then

0 commit comments

Comments
 (0)