1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the jquery-querybuilder-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2017 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\JQuery\QueryBuilderBundle\Model; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\JQuery\QueryBuilderBundle\API\QueryBuilderValidationInterface; |
15
|
|
|
use WBW\Bundle\JQuery\QueryBuilderBundle\Serializer\JsonSerializer; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* QueryBuilder validation. |
19
|
|
|
* |
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
21
|
|
|
* @package WBW\Bundle\JQuery\QueryBuilderBundle\Model |
22
|
|
|
*/ |
23
|
|
|
class QueryBuilderValidation implements QueryBuilderValidationInterface { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Allow empty value. |
27
|
|
|
* |
28
|
|
|
* @var bool|null |
29
|
|
|
*/ |
30
|
|
|
private $allowEmptyValue; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Callback. |
34
|
|
|
* |
35
|
|
|
* @var string|null |
36
|
|
|
*/ |
37
|
|
|
private $callback; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Format. |
41
|
|
|
* |
42
|
|
|
* @var mixed |
43
|
|
|
*/ |
44
|
|
|
private $format; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Max. |
48
|
|
|
* |
49
|
|
|
* @var mixed |
50
|
|
|
*/ |
51
|
|
|
private $max; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Messages. |
55
|
|
|
* |
56
|
|
|
* @var array|null |
57
|
|
|
*/ |
58
|
|
|
private $messages; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Min. |
62
|
|
|
* |
63
|
|
|
* @var mixed |
64
|
|
|
*/ |
65
|
|
|
private $min; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Step. |
69
|
|
|
* |
70
|
|
|
* @var mixed |
71
|
|
|
*/ |
72
|
|
|
private $step; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Constructor. |
76
|
|
|
*/ |
77
|
|
|
public function __construct() { |
78
|
|
|
// NOTHING TO DO |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* {@inheritDoc} |
83
|
|
|
*/ |
84
|
|
|
public function getAllowEmptyValue(): ?bool { |
85
|
|
|
return $this->allowEmptyValue; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* {@inheritDoc} |
90
|
|
|
*/ |
91
|
|
|
public function getCallback(): ?string { |
92
|
|
|
return $this->callback; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* {@inheritDoc} |
97
|
|
|
*/ |
98
|
|
|
public function getFormat() { |
99
|
|
|
return $this->format; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* {@inheritDoc} |
104
|
|
|
*/ |
105
|
|
|
public function getMax() { |
106
|
|
|
return $this->max; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* {@inheritDoc} |
111
|
|
|
*/ |
112
|
|
|
public function getMessages(): ?array { |
113
|
|
|
return $this->messages; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* {@inheritDoc} |
118
|
|
|
*/ |
119
|
|
|
public function getMin() { |
120
|
|
|
return $this->min; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* {@inheritDoc} |
125
|
|
|
*/ |
126
|
|
|
public function getStep() { |
127
|
|
|
return $this->step; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* {@inheritDoc} |
132
|
|
|
*/ |
133
|
|
|
public function jsonSerialize(): array { |
134
|
|
|
return JsonSerializer::serializeQueryBuilderValidation($this); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Set the allow empty value. |
139
|
|
|
* |
140
|
|
|
* @param bool|null $allowEmptyValue The allow empty value. |
141
|
|
|
* @return QueryBuilderValidationInterface Returns this validation. |
142
|
|
|
*/ |
143
|
|
|
public function setAllowEmptyValue(?bool $allowEmptyValue): QueryBuilderValidationInterface { |
144
|
|
|
$this->allowEmptyValue = $allowEmptyValue; |
145
|
|
|
return $this; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Set the callback. |
150
|
|
|
* |
151
|
|
|
* @param string|null $callback The callback. |
152
|
|
|
* @return QueryBuilderValidationInterface Returns this validation. |
153
|
|
|
*/ |
154
|
|
|
public function setCallback(?string $callback): QueryBuilderValidationInterface { |
155
|
|
|
$this->callback = $callback; |
156
|
|
|
return $this; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Set the format. |
161
|
|
|
* |
162
|
|
|
* @param mixed $format The format. |
163
|
|
|
* @return QueryBuilderValidationInterface Returns this validation. |
164
|
|
|
*/ |
165
|
|
|
public function setFormat($format): QueryBuilderValidationInterface { |
166
|
|
|
$this->format = $format; |
167
|
|
|
return $this; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Set the max. |
172
|
|
|
* |
173
|
|
|
* @param mixed $max The max. |
174
|
|
|
* @return QueryBuilderValidationInterface Returns this validation. |
175
|
|
|
*/ |
176
|
|
|
public function setMax($max): QueryBuilderValidationInterface { |
177
|
|
|
$this->max = $max; |
178
|
|
|
return $this; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Set the messages. |
183
|
|
|
* |
184
|
|
|
* @param array|null $messages The messages. |
185
|
|
|
* @return QueryBuilderValidationInterface Returns this validation. |
186
|
|
|
*/ |
187
|
|
|
public function setMessages(?array $messages): QueryBuilderValidationInterface { |
188
|
|
|
$this->messages = $messages; |
189
|
|
|
return $this; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* Set the min. |
194
|
|
|
* |
195
|
|
|
* @param mixed $min The min. |
196
|
|
|
* @return QueryBuilderValidationInterface Returns this validation. |
197
|
|
|
*/ |
198
|
|
|
public function setMin($min): QueryBuilderValidationInterface { |
199
|
|
|
$this->min = $min; |
200
|
|
|
return $this; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Set the step. |
205
|
|
|
* |
206
|
|
|
* @param mixed $step The step. |
207
|
|
|
* @return QueryBuilderValidationInterface Returns this validation. |
208
|
|
|
*/ |
209
|
|
|
public function setStep($step): QueryBuilderValidationInterface { |
210
|
|
|
$this->step = $step; |
211
|
|
|
return $this; |
212
|
|
|
} |
213
|
|
|
} |
214
|
|
|
|