Skip to content

Validate that time property is valid and not in the future #749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int

if (!array_key_exists('time', $branch)) {
$messages[$path][] = sprintf('Key "time" is required for branch "%s".', $name);
} elseif (isset($branch['time'])) {
$timestamp = is_int($branch['time']) ? $branch['time'] : strtotime($branch['time']);

if ($timestamp === false) {
$messages[$path][] = sprintf('"time" is invalid for branch "%s", given "%s".', $name, $branch['time']);
} elseif ($timestamp > time()) {
$messages[$path][] = sprintf('"time" cannot be in the future for branch "%s", given "%s".', $name, $branch['time']);
}
}

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