1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Validator.php - Trait for validation functions |
5
|
|
|
* |
6
|
|
|
* @package jaxon-core |
7
|
|
|
* @author Thierry Feuzeu <[email protected]> |
8
|
|
|
* @copyright 2016 Thierry Feuzeu <[email protected]> |
9
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License |
10
|
|
|
* @link https://github.com/jaxon-php/jaxon-core |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace Jaxon\Utils\Traits; |
14
|
|
|
|
15
|
|
|
use Jaxon\Utils\Container; |
16
|
|
|
|
17
|
|
|
trait Validator |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Validate a function name |
21
|
|
|
* |
22
|
|
|
* @param string $sName The function name |
23
|
|
|
* |
24
|
|
|
* @return bool True if the function name is valid, and false if not |
25
|
|
|
*/ |
26
|
|
|
public function validateFunction($sName) |
27
|
|
|
{ |
28
|
|
|
return Container::getInstance()->getValidator()->validateFunction($sName); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Validate an event name |
33
|
|
|
* |
34
|
|
|
* @param string $sName The event name |
35
|
|
|
* |
36
|
|
|
* @return bool True if the event name is valid, and false if not |
37
|
|
|
*/ |
38
|
|
|
public function validateEvent($sName) |
39
|
|
|
{ |
40
|
|
|
return Container::getInstance()->getValidator()->validateEvent($sName); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Validate a class name |
45
|
|
|
* |
46
|
|
|
* @param string $sName The class name |
47
|
|
|
* |
48
|
|
|
* @return bool True if the class name is valid, and false if not |
49
|
|
|
*/ |
50
|
|
|
public function validateClass($sName) |
51
|
|
|
{ |
52
|
|
|
return Container::getInstance()->getValidator()->validateClass($sName); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Validate a method name |
57
|
|
|
* |
58
|
|
|
* @param string $sName The function name |
59
|
|
|
* |
60
|
|
|
* @return bool True if the method name is valid, and false if not |
61
|
|
|
*/ |
62
|
|
|
public function validateMethod($sName) |
63
|
|
|
{ |
64
|
|
|
return Container::getInstance()->getValidator()->validateMethod($sName); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Validate an uploaded file |
69
|
|
|
* |
70
|
|
|
* @param array $aUploadedFile The file data received in the $_FILES array |
71
|
|
|
* |
72
|
|
|
* @return bool True if the file data are valid, and false if not |
73
|
|
|
*/ |
74
|
|
|
public function validateUploadedFile(array $aUploadedFile) |
75
|
|
|
{ |
76
|
|
|
return Container::getInstance()->getValidator()->validateUploadedFile($aUploadedFile); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|