Skip to content

Commit 1148a51

Browse files
liucfjasonvarga
andauthored
[5.x] Fix validation of date field nested in a replicator (#11692)
Co-authored-by: Jason Varga <[email protected]>
1 parent 4f048d8 commit 1148a51

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/Fieldtypes/Date.php

+11-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Carbon\Exceptions\InvalidFormatException;
66
use Illuminate\Support\Carbon;
77
use Illuminate\Support\Facades\Validator;
8+
use Illuminate\Validation\ValidationException;
89
use InvalidArgumentException;
910
use Statamic\Facades\GraphQL;
1011
use Statamic\Fields\Fieldtype;
@@ -371,10 +372,16 @@ public function secondsEnabled()
371372

372373
public function preProcessValidatable($value)
373374
{
374-
Validator::make(
375-
[$this->field->handle() => $value],
376-
[$this->field->handle() => [new ValidationRule($this)]],
377-
)->validate();
375+
try {
376+
Validator::make(
377+
['field' => $value],
378+
['field' => [new ValidationRule($this)]],
379+
[],
380+
['field' => $this->field->display()],
381+
)->validate();
382+
} catch (ValidationException $e) {
383+
throw ValidationException::withMessages([$this->field->fieldPathPrefix() => $e->errors()['field']]);
384+
}
378385

379386
if ($value === null) {
380387
return null;

0 commit comments

Comments
 (0)