Skip to content

Commit ab6f410

Browse files
authored
Merge pull request #1295 from livewire/josh/fix-date-range-validation
Fix `DateRangeSynth` so the `DateRange` can be validated
2 parents 7992957 + 5ce17be commit ab6f410

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/DateRangeSynth.php

+13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ static function matchByType($type) {
1717
return $type === DateRange::class;
1818
}
1919

20+
static function unwrapForValidation($target) {
21+
$data = [
22+
'start' => $target->start()?->format('Y-m-d'),
23+
'end' => $target->end()?->format('Y-m-d'),
24+
];
25+
26+
$preset = $target->preset();
27+
28+
$preset && $data['preset'] = $preset->value;
29+
30+
return $data;
31+
}
32+
2033
static function hydrateFromType($type, $value) {
2134
if ($value === '' || $value === null) return null;
2235

stubs/resources/views/flux/error.blade.php

+5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
@props([
22
'name' => null,
33
'message' => null,
4+
'nested' => true,
45
])
56

67
@php
78
$message ??= $name ? $errors->first($name) : null;
89
10+
if ((is_null($message) || $message === '') && filter_var($nested, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== false) {
11+
$message = $errors->first($name . '.*');
12+
}
13+
914
$classes = Flux::classes('mt-3 text-sm font-medium text-red-500 dark:text-red-400')
1015
->add($message ? '' : 'hidden');
1116
@endphp

0 commit comments

Comments
 (0)