| 1 |
<?php |
| 2 |
|
| 3 |
namespace Rakit\Validation\Rules; |
| 4 |
|
| 5 |
use Rakit\Validation\Rule; |
| 6 |
|
| 7 |
class Accepted extends Rule |
| 8 |
{ |
| 9 |
/** @var bool */ |
| 10 |
protected $implicit = true; |
| 11 |
|
| 12 |
/** @var string */ |
| 13 |
protected $message = "The :attribute must be accepted"; |
| 14 |
|
| 15 |
/** |
| 16 |
* Check the $value is accepted |
| 17 |
* |
| 18 |
* @param mixed $value |
| 19 |
* @return bool |
| 20 |
*/ |
| 21 |
public function check($value): bool |
| 22 |
{ |
| 23 |
$acceptables = ['yes', 'on', '1', 1, true, 'true']; |
| 24 |
return in_array($value, $acceptables, true); |
| 25 |
} |
| 26 |
} |
| 27 |
|