mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
20 lines
473 B
PHP
20 lines
473 B
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use App\Services\Helpers\ScheduleHelper;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Lorisleiva\CronTranslator\CronTranslator;
|
|
|
|
class ValidCron implements ValidationRule
|
|
{
|
|
public function validate(string $attribute, mixed $value, \Closure $fail): void
|
|
{
|
|
try {
|
|
CronTranslator::translate($value);
|
|
} catch (\Exception $e) {
|
|
$fail(ScheduleHelper::getInvalidCronText());
|
|
}
|
|
}
|
|
}
|