-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathValidation.dpr
61 lines (50 loc) · 1.42 KB
/
Validation.dpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
library Validation;
uses
System.SysUtils,
System.Classes,
RegularExpressions;
function IsValidNumber(const phoneNumber: string): Boolean;
var
regex: TRegEx;
begin
//checks if the phone number consists of 10 digits and starts with 0
regex := TRegEx.Create('^[0]\d{9}$');
Result := regex.IsMatch(phoneNumber);
end;
function IsValidPassword(const password: string): Boolean;
var
regex: TRegEx;
begin
//check if the password is 8 characters long and contains at least one special character
regex := TRegEx.Create('^(?=.*[#^@$!%*?&])[A-Za-z\d@$#^!%*?&]{8,}$');
Result := regex.IsMatch(password);
end;
function IsValidEmail(const email: string): Boolean;
var
regex: TRegEx;
begin
//check if the email address is in a valid format
regex := TRegEx.Create('^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$');
Result := regex.IsMatch(email);
end;
function IsValidName(Const Name: String): Boolean;
var
regex: TRegEx;
begin
//check if name is valid
regex := TRegEx.Create('^[A-Z][a-z]* [A-Z][a-z]*$');
Result := regex.IsMatch(Name);
end;
function IsValidWage(Const Wage: String): Boolean;
var
regex: TRegEx;
begin
//Check if wage is valid
regex := TRegEx.Create('^\d{1,3}(?:\.\d{0,2})?$');
Result := regex.IsMatch(Wage);
end;
exports
IsValidNumber, IsValidPassword, IsValidEmail, IsValidName, IsValidWage;
{$R *.res}
begin
end.