| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Metricool\Support\Validation\Rules; |
| 6 |
|
| 7 |
class ArrayRule extends AbstractRule |
| 8 |
{ |
| 9 |
/** |
| 10 |
* Checks if the field contains an array. |
| 11 |
* @inheritDoc |
| 12 |
*/ |
| 13 |
public function validate(string $field, $value, array $data): void |
| 14 |
{ |
| 15 |
if (!is_array($value)) { |
| 16 |
$this->fail(sprintf( |
| 17 |
/* translators: %s is the field name */ |
| 18 |
__('%s must be an array.', 'metricool'), |
| 19 |
$field |
| 20 |
)); |
| 21 |
} |
| 22 |
} |
| 23 |
} |
| 24 |
|