-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcommonvalidations.php
53 lines (37 loc) · 971 Bytes
/
commonvalidations.php
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
<?php
/*
STANDARD SET OF INPUTS
1. Mobile Number (NNNNNNNNNN) - 10 digit number
2. Email ID ([email protected]) - Any email ID
3. Date (DD-MM-YYYY) - Our standard (31-31-0000 should not pass through!)
4. Time (HH:II) - Our Standard (Example - 13:15 for 01:30 Noon) (44:44 should not pass through!) {{24 Hours Format}}
5. Name (Characters only - with . DOT and space permitted) (No ' or ` or , or anything of that sort) | Maximum length of 30
C1. Date Comparator
C2. Time Comparator
*/
/*
1. Mobile Number Valdiation
*/
function validateMobileNumber($phone){
if(preg_match("/^[789]\d{9}$/", $phone)){
return true;
}
else{
return false;
}
}
/*
C1. Date Comparator
*/
function isSecondDateGreater($first, $second){
//This expects $first and $second in OUR STANDARDS
$formattedFirst = date('Ymd', strtotime($first));
$formattedSecond = date('Ymd', strtotime($second));
if($formattedFirst <= $formattedSecond){
return 1;
}
else{
return 0;
}
}
?>