Skip to content

Commit

Permalink
Validate Scheduler CronExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
shaedrich authored Dec 18, 2024
1 parent bf16f38 commit 2054430
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Illuminate/Console/Scheduling/ManagesFrequencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Console\Scheduling;

use Cron\CronExpression;
use Illuminate\Support\Carbon;
use InvalidArgumentException;

Expand All @@ -15,6 +16,10 @@ trait ManagesFrequencies
*/
public function cron($expression)
{
if (!CronExpression::isValidExpression()) {
throw new InvalidArgumentException("The expression [$expression] is not a valid cron expression.");
}

$this->expression = $expression;

return $this;
Expand Down

0 comments on commit 2054430

Please sign in to comment.