-
Notifications
You must be signed in to change notification settings - Fork 1
/
validators.php
50 lines (44 loc) · 1002 Bytes
/
validators.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
<?php
class Validators {
/**
* Validate Emails
* @param string $input Email to validate
* @return bool true/false
*/
function valMail($input) {
if(!filter_var($input, FILTER_VALIDATE_EMAIL))
return false;
return true;
}
/**
* Validate Integers
* @param int $input Integer to validate
* @return bool true/false
*/
function valInt($input) {
if (filter_var($input, FILTER_VALIDATE_INT) || filter_var($input, FILTER_VALIDATE_INT) === 0)
return true;
return false;
}
/**
* Validate URLs
* @param string $input URL to validate
* @return bool true/false
*/
function valUrl($input) {
if(!filter_var($input, FILTER_VALIDATE_URL))
return false;
return true;
}
/**
* Validate IPs
* @param string $input IP to validate
* @return bool true/false
*/
function valIp($input) {
if(!filter_var($input, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE))
return false;
return true;
}
}
?>