| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Metricool\Features\UserSettings\Rules; |
| 6 |
|
| 7 |
use Metricool\Support\Validation\Rules\AbstractRule; |
| 8 |
|
| 9 |
class FirstDayOfWeekRule extends AbstractRule |
| 10 |
{ |
| 11 |
/** |
| 12 |
* Checks if the value is a valid first day of the week (1 or 7) |
| 13 |
* @inheritDoc |
| 14 |
*/ |
| 15 |
public function validate(string $field, $value, array $data): void |
| 16 |
{ |
| 17 |
if ($value !== '1' && $value !== '7') { |
| 18 |
$this->fail(esc_html__('Please enter a valid day of the week (1 or 7)', 'metricool')); |
| 19 |
} |
| 20 |
} |
| 21 |
} |
| 22 |
|