Skip to content

Commit c535fd8

Browse files
committed
Validate that time property is valid and not in the future
1 parent 8ff8173 commit c535fd8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

validator.php

+8
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
177177

178178
if (!array_key_exists('time', $branch)) {
179179
$messages[$path][] = sprintf('Key "time" is required for branch "%s".', $name);
180+
} elseif (isset($branch['time'])) {
181+
$timestamp = is_int($branch['time']) ? $branch['time'] : strtotime($branch['time']);
182+
183+
if ($timestamp === false) {
184+
$messages[$path][] = sprintf('"time" is invalid for branch "%s", given "%s".', $name, $branch['time']);
185+
} elseif ($timestamp > time()) {
186+
$messages[$path][] = sprintf('"time" cannot be in the future for branch "%s", given "%s".', $name, $branch['time']);
187+
}
180188
}
181189

182190
if (!isset($branch['versions'])) {

0 commit comments

Comments
 (0)