1 | <?php |
||
30 | class NumberValidator implements ValidatorInterface |
||
31 | { |
||
32 | |||
33 | use AllowEmpty, |
||
34 | Messages, |
||
35 | OnScenario, |
||
36 | Safe, |
||
37 | SkipOnError; |
||
38 | |||
39 | /** |
||
40 | * Whether the attribute value can only be an integer. Defaults to false. |
||
41 | * @var boolean |
||
42 | */ |
||
43 | public $integerOnly = false; |
||
44 | |||
45 | /** |
||
46 | * Upper limit of the number. Defaults to null, meaning no upper limit. |
||
47 | * @var integer|float |
||
48 | */ |
||
49 | public $max = NULL; |
||
50 | |||
51 | /** |
||
52 | * Lower limit of the number. Defaults to null, meaning no lower limit. |
||
53 | * @var integer|float |
||
54 | */ |
||
55 | public $min = NULL; |
||
56 | |||
57 | /** |
||
58 | * Number must be greater than. Defaults to null, meaning no constraint. |
||
59 | * @var integer|float |
||
60 | */ |
||
61 | public $gt = null; |
||
62 | |||
63 | /** |
||
64 | * Number must be lesser than. Defaults to null, meaning no constraint. |
||
65 | * @var integer|float |
||
66 | */ |
||
67 | public $lt= null; |
||
68 | |||
69 | /** |
||
70 | * Deprecated: Use `msgTooSmall` instead |
||
71 | * @var string user-defined error message used when the value is too big. |
||
72 | * @deprecated Use `msgTooSmall` instead |
||
73 | */ |
||
74 | public $tooBig = NULL; |
||
75 | |||
76 | /** |
||
77 | * Deprecated: Use `msgTooBig` instead |
||
78 | * @var string user-defined error message used when the value is too small. |
||
79 | * @deprecated Use `msgTooBig` instead |
||
80 | */ |
||
81 | public $tooSmall = NULL; |
||
82 | |||
83 | /** |
||
84 | * Custom message to show if value is not number |
||
85 | * @Label('{attribute} must be a number') |
||
86 | * @var string |
||
87 | */ |
||
88 | public $msgNumber = ''; |
||
89 | |||
90 | /** |
||
91 | * Custom message to show if value is not integer when integer checking is |
||
92 | * enabled |
||
93 | * @Label('{attribute} must be an integer') |
||
94 | * @var string |
||
95 | */ |
||
96 | public $msgInteger = ''; |
||
97 | |||
98 | /** |
||
99 | * Custom message to show if value is over maximum |
||
100 | * @Label('{attribute} is too small (minimum is {min})') |
||
101 | * @var string |
||
102 | */ |
||
103 | public $msgTooSmall = ''; |
||
104 | |||
105 | /** |
||
106 | * Custom message to show if value is under minimum |
||
107 | * @Label('{attribute} is too big (maximum is {max})') |
||
108 | * @var string |
||
109 | */ |
||
110 | public $msgTooBig = ''; |
||
111 | |||
112 | /** |
||
113 | * Custom message to show if value must be greater than required |
||
114 | * @Label('{attribute} must be greater than {gt}') |
||
115 | * @var string |
||
116 | */ |
||
117 | public $msgGt = ''; |
||
118 | |||
119 | /** |
||
120 | * Custom message to show if value is lesser than required |
||
121 | * @Label('{attribute} must be lesser than {lt}') |
||
122 | * @var string |
||
123 | */ |
||
124 | public $msgLt = ''; |
||
125 | |||
126 | 11 | public function isValid(AnnotatedInterface $model, $attribute) |
|
199 | |||
200 | } |
||
201 |