Skip to content

Commit 9d11147

Browse files
author
César Cardoso
committed
refactor/overloads-em-creates
1 parent 042b765 commit 9d11147

5 files changed

+66
-15
lines changed

Samples/Demo01/Src/View/C4D.ValidateComponents.Demo01.View.Main.dfm

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ object C4DValidateComponentsDemo01ViewMain: TC4DValidateComponentsDemo01ViewMain
22
Left = 0
33
Top = 0
44
Caption = 'C4D-validate-components - Demo01'
5-
ClientHeight = 610
5+
ClientHeight = 570
66
ClientWidth = 643
77
Color = clBtnFace
88
Font.Charset = DEFAULT_CHARSET
@@ -19,15 +19,15 @@ object C4DValidateComponentsDemo01ViewMain: TC4DValidateComponentsDemo01ViewMain
1919
Left = 0
2020
Top = 0
2121
Width = 643
22-
Height = 610
22+
Height = 570
2323
Align = alClient
2424
BevelOuter = bvNone
2525
TabOrder = 0
2626
ExplicitWidth = 662
2727
ExplicitHeight = 588
2828
object pnButtons: TPanel
2929
Left = 0
30-
Top = 565
30+
Top = 525
3131
Width = 643
3232
Height = 45
3333
Align = alBottom
@@ -64,11 +64,12 @@ object C4DValidateComponentsDemo01ViewMain: TC4DValidateComponentsDemo01ViewMain
6464
Left = 0
6565
Top = 0
6666
Width = 643
67-
Height = 565
67+
Height = 525
6868
ActivePage = tabDemo
6969
Align = alClient
7070
TabOrder = 1
7171
ExplicitTop = -2
72+
ExplicitHeight = 565
7273
object tabDemo: TTabSheet
7374
Caption = 'Demo'
7475
ExplicitLeft = 0
@@ -79,9 +80,10 @@ object C4DValidateComponentsDemo01ViewMain: TC4DValidateComponentsDemo01ViewMain
7980
Left = 0
8081
Top = 0
8182
Width = 635
82-
Height = 537
83+
Height = 497
8384
Align = alClient
8485
TabOrder = 0
86+
ExplicitHeight = 537
8587
object Label1: TLabel
8688
Left = 16
8789
Top = 8
@@ -271,7 +273,7 @@ object C4DValidateComponentsDemo01ViewMain: TC4DValidateComponentsDemo01ViewMain
271273
end
272274
object GroupBox2: TGroupBox
273275
Left = 1
274-
Top = 352
276+
Top = 312
275277
Width = 633
276278
Height = 184
277279
Align = alBottom
@@ -283,6 +285,7 @@ object C4DValidateComponentsDemo01ViewMain: TC4DValidateComponentsDemo01ViewMain
283285
Font.Style = [fsBold]
284286
ParentFont = False
285287
TabOrder = 7
288+
ExplicitTop = 352
286289
object Label7: TLabel
287290
Left = 15
288291
Top = 19
@@ -485,12 +488,13 @@ object C4DValidateComponentsDemo01ViewMain: TC4DValidateComponentsDemo01ViewMain
485488
Left = 0
486489
Top = 0
487490
Width = 635
488-
Height = 537
491+
Height = 497
489492
Align = alClient
490493
BevelOuter = bvNone
491494
ParentBackground = False
492495
TabOrder = 0
493496
ExplicitTop = -2
497+
ExplicitHeight = 537
494498
object Label13: TLabel
495499
Left = 16
496500
Top = 16

Samples/Demo01/Src/View/C4D.ValidateComponents.Demo01.View.Main.pas

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ TC4DValidateComponentsDemo01ViewMain = class(TForm)
3838

3939
[FieldDisplay('Nome')]
4040
[NotEmpty]
41-
[Length(5, 20)]
41+
[Length(5, 15)]
4242
edtName: TEdit;
4343

44-
[NotEmpty]
4544
[MinMaxValue(5, 10)]
4645
edtLimit: TEdit;
4746

Src/C4D.Validate.Components.Length.pas

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ Length = class(TCustomAttribute)
1515
FMsg: string;
1616
function GetMsg: string;
1717
public
18-
constructor Create(const AMinLength, AMaxLength: Integer; const AMsg: string = '');
18+
constructor Create(const AMinLength: Integer); overload;
19+
constructor Create(const AMinLength, AMaxLength: Integer); overload;
20+
constructor Create(const AMinLength: Integer; const AMsg: string); overload;
21+
constructor Create(const AMinLength, AMaxLength: Integer; const AMsg: string); overload;
1922
procedure Validar(const ARttiField: TRttiField; const AObject: TObject);
2023
end;
2124

@@ -27,7 +30,22 @@ implementation
2730
C4D.Validate.Components.Consts,
2831
C4D.Validate.Components.Language;
2932

30-
constructor Length.Create(const AMinLength, AMaxLength: Integer; const AMsg: string = '');
33+
constructor Length.Create(const AMinLength: Integer);
34+
begin
35+
Self.Create(AMinLength, 0, '');
36+
end;
37+
38+
constructor Length.Create(const AMinLength, AMaxLength: Integer);
39+
begin
40+
Self.Create(AMinLength, AMaxLength, '');
41+
end;
42+
43+
constructor Length.Create(const AMinLength: Integer; const AMsg: string);
44+
begin
45+
Self.Create(AMinLength, 0, AMsg);
46+
end;
47+
48+
constructor Length.Create(const AMinLength, AMaxLength: Integer; const AMsg: string);
3149
begin
3250
FMinLength := AMinLength;
3351
FMaxLength := AMaxLength;

Src/C4D.Validate.Components.MinMaxDate.pas

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ MinMaxDate = class(TCustomAttribute)
1515
FMsg: string;
1616
function GetMsg: string;
1717
public
18-
constructor Create(const AMinDate, AMaxDate: string; const AMsg: string = '');
18+
constructor Create(const AMinDate: string); overload;
19+
constructor Create(const AMinDate, AMaxDate: string); overload;
20+
constructor Create(const AMinDate, AMaxDate, AMsg: string); overload;
1921
procedure Validar(const ARttiField: TRttiField; const AObject: TObject);
2022
end;
2123

@@ -27,7 +29,17 @@ implementation
2729
C4D.Validate.Components.Consts,
2830
C4D.Validate.Components.Language;
2931

30-
constructor MinMaxDate.Create(const AMinDate, AMaxDate: string; const AMsg: string = '');
32+
constructor MinMaxDate.Create(const AMinDate: string);
33+
begin
34+
Self.Create(AMinDate, '', '');
35+
end;
36+
37+
constructor MinMaxDate.Create(const AMinDate, AMaxDate: string);
38+
begin
39+
Self.Create('', AMaxDate, '');
40+
end;
41+
42+
constructor MinMaxDate.Create(const AMinDate, AMaxDate, AMsg: string);
3143
begin
3244
FMinDate := StrToDateDef(AMinDate, 0);
3345
FMaxDate := StrToDateDef(AMaxDate, 0);

Src/C4D.Validate.Components.MinMaxValue.pas

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ MinMaxValue = class(TCustomAttribute)
1515
FMsg: string;
1616
function GetMsg: string;
1717
public
18-
constructor Create(const AMinValue, AMaxValue: Integer; const AMsg: string = '');
18+
constructor Create(const AMinValue: Integer); overload;
19+
constructor Create(const AMinValue, AMaxValue: Integer); overload;
20+
constructor Create(const AMinValue: Integer; const AMsg: string); overload;
21+
constructor Create(const AMinValue, AMaxValue: Integer; const AMsg: string); overload;
1922
procedure Validar(const ARttiField: TRttiField; const AObject: TObject);
2023
end;
2124

@@ -27,7 +30,22 @@ implementation
2730
C4D.Validate.Components.Consts,
2831
C4D.Validate.Components.Language;
2932

30-
constructor MinMaxValue.Create(const AMinValue, AMaxValue: Integer; const AMsg: string = '');
33+
constructor MinMaxValue.Create(const AMinValue: Integer);
34+
begin
35+
Self.Create(AMinValue, 0, '');
36+
end;
37+
38+
constructor MinMaxValue.Create(const AMinValue, AMaxValue: Integer);
39+
begin
40+
Self.Create(AMinValue, AMaxValue, '');
41+
end;
42+
43+
constructor MinMaxValue.Create(const AMinValue: Integer; const AMsg: string);
44+
begin
45+
Self.Create(AMinValue, 0, AMsg);
46+
end;
47+
48+
constructor MinMaxValue.Create(const AMinValue, AMaxValue: Integer; const AMsg: string);
3149
begin
3250
FMinValue := AMinValue;
3351
FMaxValue := AMaxValue;

0 commit comments

Comments
 (0)