Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
5 / 5 |
Truthful | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
5 / 5 |
validate | |
100.00% |
1 / 1 |
2 | |
100.00% |
4 / 4 |
|||
getInverseError | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
<?php | |
namespace Verja\Validator; | |
use Verja\Error; | |
use Verja\Validator; | |
class Truthful extends Validator | |
{ | |
/** | |
* Validate $value | |
* | |
* @param mixed $value | |
* @param array $context | |
* @return bool | |
*/ | |
public function validate($value, array $context = []): bool | |
{ | |
if (!$value) { | |
$this->error = new Error('NOT_TRUTHFUL', $value, 'value should be truthful'); | |
return false; | |
} | |
return true; | |
} | |
public function getInverseError($value) | |
{ | |
return new Error('IS_TRUTHFUL', $value, 'value should not be truthful'); | |
} | |
} |