Skip to content

Commit 8beb4e4

Browse files
authored
Add multi-value support for minutes+hours
1 parent 35c0cd7 commit 8beb4e4

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/CronLint.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,23 @@ function ($v) {
156156
'cmdoverflow' => '/^(\d|\*)$/i'
157157
];
158158

159-
if (!preg_match($regEx['minhour'], $mins)) {
160-
$errors[] = sprintf("Minutes invalid value: %s", $mins);
159+
160+
$offset = 0;
161+
$mins = explode(',', $mins);
162+
foreach ($mins as $min) {
163+
if (!preg_match($regEx['minhour'], $min)) {
164+
$errors[] = sprintf("Minute[%d] invalid value: %s", $offset, $min);
165+
}
166+
++$offset;
161167
}
162-
if (!preg_match($regEx['minhour'], $hours)) {
163-
$errors[] = sprintf("Hours invalid value: %s", $hours);
168+
169+
$offset = 0;
170+
$hours = explode(',', $hours);
171+
foreach ($hours as $hour) {
172+
if (!preg_match($regEx['minhour'], $hour)) {
173+
$errors[] = sprintf("Hour[%d] invalid value: %s", $offset, $hour);
174+
}
175+
++$offset;
164176
}
165177

166178
$offset = 0;

0 commit comments

Comments
 (0)