-
Notifications
You must be signed in to change notification settings - Fork 0
/
ValidationRule.php
110 lines (97 loc) · 2.42 KB
/
ValidationRule.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
namespace Izica;
use Phalcon\Validation\Validator\Email;
use Phalcon\Validation\Validator\StringLength;
use Phalcon\Validation\Validator\Between;
use Phalcon\Validation\Validator\File;
use Phalcon\Validation\Validator\UniquenessValidator;
use Phalcon\Validation\Validator\Callback;
use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Numericality;
use Phalcon\Validation\Validator\Url;
use Phalcon\Validation\Validator\Date;
use Phalcon\Validation\Validator\Regex;
class ValidationRule {
public static function required(
$arOptions = [
'message' => ':field is required'
]
) {
return [
'type' => 'required',
'options' => $arOptions
];
}
public static function numeric(
$arOptions = [
'message' => ':field is not numeric'
]
) {
return [
'type' => 'numeric',
'options' => $arOptions
];
}
public static function url(
$arOptions = [
'message' => ':field must be a url'
]
) {
return [
'type' => 'url',
'options' => $arOptions
];
}
public static function email(
$arOptions = [
'message' => ':field is not valid'
]
) {
return [
'type' => 'email',
'options' => $arOptions
];
}
public static function unique($arOptions) {
return [
'type' => 'unique',
'options' => $arOptions
];
}
public static function callback($arOptions) {
return [
'type' => 'callback',
'options' => $arOptions
];
}
public static function length($arOptions) {
return [
'type' => 'length',
'options' => $arOptions
];
}
public static function file($arOptions) {
return [
'type' => 'file',
'options' => $arOptions
];
}
public static function between($arOptions) {
return [
'type' => 'between',
'options' => $arOptions
];
}
public static function date($arOptions) {
return [
'type' => 'date',
'options' => $arOptions
];
}
public static function regex($arOptions) {
return [
'type' => 'regex',
'options' => $arOptions
];
}
}