@@ -39,9 +39,10 @@ |
||
39 | 39 | |
40 | 40 | public function validate($data): Result |
41 | 41 | { |
42 | - if (ctype_alnum(str_replace($this->allowedSpecialChars, '', $data))) |
|
43 | - return new Success(); |
|
44 | - else |
|
45 | - return new Failure(new RuleError(RuleErrorCode::NOT_ALNUM, 'String is not Alphanumeric.')); |
|
42 | + if (ctype_alnum(str_replace($this->allowedSpecialChars, '', $data))) { |
|
43 | + return new Success(); |
|
44 | + } else { |
|
45 | + return new Failure(new RuleError(RuleErrorCode::NOT_ALNUM, 'String is not Alphanumeric.')); |
|
46 | + } |
|
46 | 47 | } |
47 | 48 | } |
48 | 49 | \ No newline at end of file |
@@ -27,8 +27,9 @@ |
||
27 | 27 | { |
28 | 28 | $numericResult = (new Numeric())->validate($value); |
29 | 29 | |
30 | - if (!$numericResult->isValid()) |
|
31 | - return new $numericResult; |
|
30 | + if (!$numericResult->isValid()) { |
|
31 | + return new $numericResult; |
|
32 | + } |
|
32 | 33 | |
33 | 34 | if (filter_var(str_replace($this->allowedSpecialChars, '', $value), FILTER_VALIDATE_INT) !== false) { |
34 | 35 | return new Success(); |
@@ -27,11 +27,13 @@ |
||
27 | 27 | { |
28 | 28 | $numericResult = (new Numeric())->validate($value); |
29 | 29 | |
30 | - if (!$numericResult->isValid()) |
|
31 | - return new $numericResult; |
|
30 | + if (!$numericResult->isValid()) { |
|
31 | + return new $numericResult; |
|
32 | + } |
|
32 | 33 | |
33 | - if ($value > 0) |
|
34 | - return new Success(); |
|
34 | + if ($value > 0) { |
|
35 | + return new Success(); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | return new Failure(new RuleError(RuleErrorCode::NOT_POSITIVE, 'The supplied number is not positive')); |
37 | 39 | } |
@@ -36,11 +36,13 @@ |
||
36 | 36 | { |
37 | 37 | $numericResult = (new Numeric())->validate($value); |
38 | 38 | |
39 | - if (!$numericResult->isValid()) |
|
40 | - return new $numericResult; |
|
39 | + if (!$numericResult->isValid()) { |
|
40 | + return new $numericResult; |
|
41 | + } |
|
41 | 42 | |
42 | - if ($value == $this->expected) |
|
43 | - return new Success(); |
|
43 | + if ($value == $this->expected) { |
|
44 | + return new Success(); |
|
45 | + } |
|
44 | 46 | |
45 | 47 | return new Failure(new RuleError(RuleErrorCode::LESS_THAN_MINIMUM, |
46 | 48 | 'The supplied number is less than the expectedimum value')); |
@@ -36,11 +36,13 @@ |
||
36 | 36 | { |
37 | 37 | $numericResult = (new Numeric())->validate($value); |
38 | 38 | |
39 | - if (!$numericResult->isValid()) |
|
40 | - return new $numericResult; |
|
39 | + if (!$numericResult->isValid()) { |
|
40 | + return new $numericResult; |
|
41 | + } |
|
41 | 42 | |
42 | - if ($value <= $this->max) |
|
43 | - return new Success(); |
|
43 | + if ($value <= $this->max) { |
|
44 | + return new Success(); |
|
45 | + } |
|
44 | 46 | |
45 | 47 | return new Failure(new RuleError(RuleErrorCode::EXCEEDS_MAXIMUM, 'The supplied number exceeds the maximum value')); |
46 | 48 | } |
@@ -27,11 +27,13 @@ |
||
27 | 27 | { |
28 | 28 | $numericResult = (new Numeric())->validate($value); |
29 | 29 | |
30 | - if (!$numericResult->isValid()) |
|
31 | - return new $numericResult; |
|
30 | + if (!$numericResult->isValid()) { |
|
31 | + return new $numericResult; |
|
32 | + } |
|
32 | 33 | |
33 | - if ($value < 0) |
|
34 | - return new Success(); |
|
34 | + if ($value < 0) { |
|
35 | + return new Success(); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | return new Failure(new RuleError(RuleErrorCode::NOT_NEGATIVE, 'The supplied number is not negative')); |
37 | 39 | } |
@@ -36,11 +36,13 @@ |
||
36 | 36 | { |
37 | 37 | $numericResult = (new Numeric())->validate($value); |
38 | 38 | |
39 | - if (!$numericResult->isValid()) |
|
40 | - return new $numericResult; |
|
39 | + if (!$numericResult->isValid()) { |
|
40 | + return new $numericResult; |
|
41 | + } |
|
41 | 42 | |
42 | - if ($value >= $this->min) |
|
43 | - return new Success(); |
|
43 | + if ($value >= $this->min) { |
|
44 | + return new Success(); |
|
45 | + } |
|
44 | 46 | |
45 | 47 | return new Failure(new RuleError(RuleErrorCode::LESS_THAN_MINIMUM, |
46 | 48 | 'The supplied number is less than the minimum value')); |
@@ -26,7 +26,7 @@ |
||
26 | 26 | * @param array|Error $errors |
27 | 27 | * @param int $code |
28 | 28 | */ |
29 | - public function __construct(string $message = "", $errors = [], int $code = 0) |
|
29 | + public function __construct(string $message = "", $errors = [ ], int $code = 0) |
|
30 | 30 | { |
31 | 31 | parent::__construct($message, $code); |
32 | 32 | $this->errors = $errors; |