Skip to content

Commit e627a19

Browse files
author
César Cardoso
committed
commit/initial
1 parent 45d0e16 commit e627a19

10 files changed

Lines changed: 1596 additions & 0 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
program C4DValidateComponentsDemo01;
2+
3+
uses
4+
Vcl.Forms,
5+
C4DValidateComponentsDemo01.View.Main in 'Src\View\C4DValidateComponentsDemo01.View.Main.pas' {C4DValidateComponentsDemo01ViewMain},
6+
C4D.Validate.Components.Components in '..\..\Src\C4D.Validate.Components.Components.pas',
7+
C4D.Validate.Components.NotEmpty in '..\..\Src\C4D.Validate.Components.NotEmpty.pas',
8+
C4D.Validate.Components.Length in '..\..\Src\C4D.Validate.Components.Length.pas',
9+
C4D.Validate.Components.MinMaxValue in '..\..\Src\C4D.Validate.Components.MinMaxValue.pas',
10+
C4D.Validate.Components in '..\..\Src\C4D.Validate.Components.pas';
11+
12+
{$R *.res}
13+
14+
15+
begin
16+
Application.Initialize;
17+
Application.MainFormOnTaskbar := True;
18+
Application.CreateForm(TC4DValidateComponentsDemo01ViewMain, C4DValidateComponentsDemo01ViewMain);
19+
Application.Run;
20+
21+
end.

Samples/Demo01/C4DValidateComponentsDemo01.dproj

Lines changed: 975 additions & 0 deletions
Large diffs are not rendered by default.
58.2 KB
Binary file not shown.
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
object C4DValidateComponentsDemo01ViewMain: TC4DValidateComponentsDemo01ViewMain
2+
Left = 0
3+
Top = 0
4+
Caption = 'C4D-validate-components - Demo01'
5+
ClientHeight = 533
6+
ClientWidth = 662
7+
Color = clBtnFace
8+
Font.Charset = DEFAULT_CHARSET
9+
Font.Color = clWindowText
10+
Font.Height = -11
11+
Font.Name = 'Tahoma'
12+
Font.Style = []
13+
OldCreateOrder = False
14+
PixelsPerInch = 96
15+
TextHeight = 13
16+
object pnTudo: TPanel
17+
Left = 0
18+
Top = 0
19+
Width = 662
20+
Height = 533
21+
Align = alClient
22+
BevelOuter = bvNone
23+
TabOrder = 0
24+
object pnTopo: TPanel
25+
Left = 0
26+
Top = 0
27+
Width = 662
28+
Height = 488
29+
Align = alClient
30+
TabOrder = 0
31+
object Label1: TLabel
32+
Left = 24
33+
Top = 11
34+
Width = 33
35+
Height = 13
36+
Caption = 'C'#243'digo'
37+
end
38+
object Label2: TLabel
39+
Left = 24
40+
Top = 51
41+
Width = 27
42+
Height = 13
43+
Caption = 'Nome'
44+
end
45+
object Label3: TLabel
46+
Left = 24
47+
Top = 91
48+
Width = 43
49+
Height = 13
50+
Caption = 'Limite R$'
51+
end
52+
object Label4: TLabel
53+
Left = 24
54+
Top = 133
55+
Width = 20
56+
Height = 13
57+
Caption = 'Tipo'
58+
end
59+
object edtCodigo: TEdit
60+
Left = 24
61+
Top = 27
62+
Width = 601
63+
Height = 21
64+
TabOrder = 0
65+
Text = '10'
66+
end
67+
object edtNome: TEdit
68+
Left = 24
69+
Top = 67
70+
Width = 601
71+
Height = 21
72+
TabOrder = 1
73+
Text = 'C'#233'sar Cardoso'
74+
end
75+
object edtLimite: TEdit
76+
Left = 24
77+
Top = 106
78+
Width = 601
79+
Height = 21
80+
TabOrder = 2
81+
Text = '10,00'
82+
end
83+
object cBoxTipoJuridico: TComboBox
84+
Left = 24
85+
Top = 152
86+
Width = 601
87+
Height = 21
88+
Style = csDropDownList
89+
TabOrder = 3
90+
Items.Strings = (
91+
'Pessoa F'#237'sica'
92+
'Pessoa Jur'#237'dica')
93+
end
94+
object ckAtivo: TCheckBox
95+
Left = 24
96+
Top = 179
97+
Width = 97
98+
Height = 17
99+
Caption = 'Ativo'
100+
Checked = True
101+
State = cbChecked
102+
TabOrder = 4
103+
end
104+
object rdGroupSexo: TRadioGroup
105+
Left = 24
106+
Top = 202
107+
Width = 265
108+
Height = 39
109+
Caption = ' Sexo '
110+
Columns = 2
111+
Items.Strings = (
112+
'Masculino'
113+
'Feminino')
114+
TabOrder = 5
115+
end
116+
object Memo1: TMemo
117+
Left = 24
118+
Top = 247
119+
Width = 601
120+
Height = 34
121+
ScrollBars = ssVertical
122+
TabOrder = 6
123+
end
124+
object PageControl1: TPageControl
125+
Left = 24
126+
Top = 318
127+
Width = 553
128+
Height = 131
129+
ActivePage = TabSheet2
130+
TabOrder = 7
131+
object TabSheet1: TTabSheet
132+
Caption = 'TabSheet1'
133+
ExplicitLeft = 0
134+
ExplicitTop = 0
135+
ExplicitWidth = 0
136+
ExplicitHeight = 0
137+
object Edit2: TEdit
138+
Left = 32
139+
Top = 32
140+
Width = 121
141+
Height = 21
142+
TabOrder = 0
143+
end
144+
end
145+
object TabSheet2: TTabSheet
146+
Caption = 'TabSheet2'
147+
ImageIndex = 1
148+
object PageControl2: TPageControl
149+
Left = 0
150+
Top = 0
151+
Width = 545
152+
Height = 103
153+
ActivePage = TabSheet4
154+
Align = alClient
155+
TabOrder = 0
156+
object TabSheet3: TTabSheet
157+
Caption = 'TabSheet3'
158+
ExplicitLeft = 0
159+
ExplicitTop = 0
160+
ExplicitWidth = 0
161+
ExplicitHeight = 0
162+
object Edit1: TEdit
163+
Left = 32
164+
Top = 32
165+
Width = 121
166+
Height = 21
167+
TabOrder = 0
168+
end
169+
end
170+
object TabSheet4: TTabSheet
171+
Caption = 'TabSheet4'
172+
ImageIndex = 1
173+
object Panel1: TPanel
174+
Left = 0
175+
Top = 0
176+
Width = 537
177+
Height = 75
178+
Align = alClient
179+
BevelInner = bvLowered
180+
TabOrder = 0
181+
object GroupBox1: TGroupBox
182+
Left = 2
183+
Top = 2
184+
Width = 533
185+
Height = 71
186+
Align = alClient
187+
Caption = 'GroupBox1'
188+
TabOrder = 0
189+
object Label5: TLabel
190+
Left = 11
191+
Top = 16
192+
Width = 89
193+
Height = 13
194+
Caption = 'Teste com abas'
195+
Font.Charset = DEFAULT_CHARSET
196+
Font.Color = clWindowText
197+
Font.Height = -11
198+
Font.Name = 'Tahoma'
199+
Font.Style = [fsBold]
200+
ParentFont = False
201+
end
202+
object edtTesteComAbas: TEdit
203+
Left = 11
204+
Top = 32
205+
Width = 345
206+
Height = 21
207+
TabOrder = 0
208+
end
209+
end
210+
end
211+
end
212+
end
213+
end
214+
end
215+
end
216+
object pnBotoes: TPanel
217+
Left = 0
218+
Top = 488
219+
Width = 662
220+
Height = 45
221+
Align = alBottom
222+
Padding.Left = 3
223+
Padding.Top = 3
224+
Padding.Right = 3
225+
Padding.Bottom = 3
226+
TabOrder = 1
227+
object btnValidar: TButton
228+
Left = 4
229+
Top = 4
230+
Width = 168
231+
Height = 37
232+
Align = alLeft
233+
Caption = 'Validar'
234+
TabOrder = 0
235+
OnClick = btnValidarClick
236+
end
237+
end
238+
end
239+
end
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
unit C4DValidateComponentsDemo01.View.Main;
2+
3+
interface
4+
5+
uses
6+
Winapi.Windows,
7+
Winapi.Messages,
8+
System.SysUtils,
9+
System.Variants,
10+
System.Classes,
11+
Vcl.Graphics,
12+
Vcl.Controls,
13+
Vcl.Forms,
14+
Vcl.Dialogs,
15+
Vcl.StdCtrls,
16+
Vcl.ExtCtrls,
17+
System.RTTI,
18+
C4D.Validate.Components.NotEmpty,
19+
C4D.Validate.Components.Length,
20+
C4D.Validate.Components.MinMaxValue,
21+
Vcl.ComCtrls;
22+
23+
type
24+
TC4DValidateComponentsDemo01ViewMain = class(TForm)
25+
pnTudo: TPanel;
26+
pnTopo: TPanel;
27+
Label1: TLabel;
28+
Label2: TLabel;
29+
Label3: TLabel;
30+
Label4: TLabel;
31+
32+
[NotEmpty]
33+
edtCodigo: TEdit;
34+
35+
[NotEmpty]
36+
[Length(2, 5)]
37+
//'Texto deve ter entre <min> e <max> caracteres'
38+
edtNome: TEdit;
39+
40+
[NotEmpty]
41+
[MinMaxValue(5, 50)]
42+
edtLimite: TEdit;
43+
44+
[NotEmpty]
45+
cBoxTipoJuridico: TComboBox;
46+
47+
[NotEmpty]
48+
rdGroupSexo: TRadioGroup;
49+
50+
[NotEmpty]
51+
edtTesteComAbas: TEdit;
52+
53+
ckAtivo: TCheckBox;
54+
pnBotoes: TPanel;
55+
btnValidar: TButton;
56+
Memo1: TMemo;
57+
PageControl1: TPageControl;
58+
TabSheet1: TTabSheet;
59+
Edit2: TEdit;
60+
TabSheet2: TTabSheet;
61+
PageControl2: TPageControl;
62+
TabSheet3: TTabSheet;
63+
Edit1: TEdit;
64+
TabSheet4: TTabSheet;
65+
Panel1: TPanel;
66+
GroupBox1: TGroupBox;
67+
Label5: TLabel;
68+
procedure btnValidarClick(Sender: TObject);
69+
private
70+
public
71+
end;
72+
73+
var
74+
C4DValidateComponentsDemo01ViewMain: TC4DValidateComponentsDemo01ViewMain;
75+
76+
implementation
77+
78+
{$R *.dfm}
79+
80+
81+
procedure TC4DValidateComponentsDemo01ViewMain.btnValidarClick(Sender: TObject);
82+
var
83+
LRttiContext: TRttiContext;
84+
LRttiType: TRttiType;
85+
LRttiField: TRttiField;
86+
LCustomAttribute: TCustomAttribute;
87+
LComponent: TComponent;
88+
begin
89+
LRttiContext := TRttiContext.Create;
90+
try
91+
LRttiType := LRttiContext.GetType(TC4DValidateComponentsDemo01ViewMain);
92+
93+
for LRttiField in LRttiType.GetFields do
94+
begin
95+
for LCustomAttribute in LRttiField.GetAttributes do
96+
begin
97+
if(LCustomAttribute is NotEmpty)then
98+
NotEmpty(LCustomAttribute).Validar(LRttiField, Self);
99+
100+
if(LCustomAttribute is Length)then
101+
Length(LCustomAttribute).Validar(LRttiField, Self);
102+
103+
if(LCustomAttribute is MinMaxValue)then
104+
MinMaxValue(LCustomAttribute).Validar(LRttiField, Self);
105+
end;
106+
end;
107+
finally
108+
LRttiContext.Free;
109+
end;
110+
111+
ShowMeSsage('SUCESSO')
112+
end;
113+
114+
end.

0 commit comments

Comments
 (0)