Skip to content

Commit 8130426

Browse files
committed
Implement Tobi feedback
1 parent 1c2cb4f commit 8130426

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

webapp/src/Entity/Contest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,15 +1260,10 @@ public function getFreezeData(): FreezeData
12601260
return new FreezeData($this);
12611261
}
12621262

1263-
public function checkValidTimeString(string $timeString): bool {
1263+
public function checkValidTimeString(string $timeString): void {
12641264
if (preg_match("/^[+-]?\d+:\d\d(:\d\d(\.\d{1,6})?)?$/", $timeString) !== 1) {
1265-
try {
1266-
$date = new DateTime($timeString);
1267-
} catch (Exception) {
1268-
return false;
1269-
}
1265+
$date = new DateTime($timeString);
12701266
}
1271-
return true;
12721267
}
12731268

12741269
#[ORM\PrePersist]
@@ -1286,9 +1281,11 @@ public function validate(ExecutionContextInterface $context): void
12861281
foreach (['Activate', 'Deactivate', 'Start', 'End', 'Freeze', 'Unfreeze'] as $timeString) {
12871282
$tmpValue = $this->{'get' . $timeString . 'timeString'}();
12881283
if ($tmpValue === null) continue;
1289-
if (!$this->checkValidTimeString($tmpValue)) {
1284+
try {
1285+
$this->checkValidTimeString($tmpValue))
1286+
} catch (Exception $e) {
12901287
$context
1291-
->buildViolation("Can't parse this time.")
1288+
->buildViolation("Can't parse this time," . $e->message)
12921289
->atPath(strtolower($timeString) . "timeString")
12931290
->addViolation();
12941291
}

0 commit comments

Comments
 (0)