We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f9e1ac3 commit 5a3e7beCopy full SHA for 5a3e7be
src/ValidationRules/NumericValidation.php
@@ -11,6 +11,7 @@
11
use ArrayUtils\ValidationRule;
12
13
class NumericValidation implements ValidationRule {
14
+ private $allowNull = false;
15
16
/**
17
* @return string
@@ -25,7 +26,7 @@ public function getIdentifier() {
25
26
* @return array
27
*/
28
public function validate($value) {
- if (!is_numeric($value)) {
29
+ if (($value === null && !$this->allowNull) || !is_numeric($value)) {
30
return array("Campo não é numérico.");
31
}
32
@@ -36,5 +37,6 @@ public function validate($value) {
36
37
* @param mixed $params
38
39
public function setParams($params) {
40
+ $this->allowNull = isset($params[0]) && $params[0] == "nullable";
41
42
0 commit comments