1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony). |
4
|
|
|
* |
5
|
|
|
* Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics) |
6
|
|
|
* |
7
|
|
|
* This program is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License as published |
9
|
|
|
* by the Free Software Foundation, either version 3 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License |
18
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace App\Validator\Constraints\BigDecimal; |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual; |
25
|
|
|
use Symfony\Component\Validator\Constraints\NumberConstraintTrait; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @Annotation |
29
|
|
|
* @Target({"PROPERTY", "METHOD", "ANNOTATION"}) |
30
|
|
|
* |
31
|
|
|
* @author Jan Schädlich <[email protected]> |
32
|
|
|
*/ |
33
|
|
|
class BigDecimalPositiveOrZero extends GreaterThanOrEqual |
34
|
|
|
{ |
35
|
|
|
use NumberConstraintTrait; |
36
|
|
|
|
37
|
|
|
public $message = 'This value should be either positive or zero.'; |
38
|
|
|
|
39
|
|
|
public function __construct($options = null) |
40
|
|
|
{ |
41
|
|
|
parent::__construct($this->configureNumberConstraintOptions($options)); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function validatedBy(): string |
45
|
|
|
{ |
46
|
|
|
return BigDecimalGreaterThenOrEqualValidator::class; |
47
|
|
|
} |
48
|
|
|
} |