Skip to content

Commit

Permalink
Widget: agenda/calendar validation of custom interval xibosignage/xib…
Browse files Browse the repository at this point in the history
  • Loading branch information
dasgarner committed Jun 5, 2023
1 parent f0a6419 commit b1e2206
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/Widget/Definition/Property.php
Expand Up @@ -23,6 +23,7 @@
namespace Xibo\Widget\Definition;

use Carbon\Carbon;
use Carbon\CarbonInterval;
use Illuminate\Support\Str;
use Respect\Validation\Validator as v;
use Xibo\Support\Exception\InvalidArgumentException;
Expand Down Expand Up @@ -242,7 +243,14 @@ public function validate(array $properties, string $stage): Property
case 'interval':
if (!empty($this->value)) {
// Try to create a date interval from it
$dateInterval = \DateInterval::createFromDateString($this->value);
$dateInterval = CarbonInterval::createFromDateString($this->value);
if ($dateInterval === false) {
throw new InvalidArgumentException(
// phpcs:ignore Generic.Files.LineLength
__('That is not a valid date interval, please use natural language such as 1 week'),
'customInterval'
);
}

// Use now and add the date interval to it
$now = Carbon::now();
Expand Down

0 comments on commit b1e2206

Please sign in to comment.