mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-20 18:31:36 +00:00
27 lines
555 B
PHP
Executable File
27 lines
555 B
PHP
Executable File
<?php
|
|
|
|
namespace App\ValidationRules;
|
|
|
|
use Cron\CronExpression;
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
|
|
class CronRule implements Rule
|
|
{
|
|
private bool $acceptCustom;
|
|
|
|
public function __construct(bool $acceptCustom = false)
|
|
{
|
|
$this->acceptCustom = $acceptCustom;
|
|
}
|
|
|
|
public function passes($attribute, $value): bool
|
|
{
|
|
return CronExpression::isValidExpression($value) || ($this->acceptCustom && $value === 'custom');
|
|
}
|
|
|
|
public function message(): string
|
|
{
|
|
return __('Invalid frequency');
|
|
}
|
|
}
|