Skip to content

[5.x] Fix validation of date field nested in a replicator #11692

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 5 commits into from
Apr 17, 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
15 changes: 11 additions & 4 deletions src/Fieldtypes/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Carbon\Exceptions\InvalidFormatException;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
use InvalidArgumentException;
use Statamic\Facades\GraphQL;
use Statamic\Fields\Fieldtype;
Expand Down Expand Up @@ -371,10 +372,16 @@ public function secondsEnabled()

public function preProcessValidatable($value)
{
Validator::make(
[$this->field->handle() => $value],
[$this->field->handle() => [new ValidationRule($this)]],
)->validate();
try {
Validator::make(
['field' => $value],
['field' => [new ValidationRule($this)]],
[],
['field' => $this->field->display()],
)->validate();
} catch (ValidationException $e) {
throw ValidationException::withMessages([$this->field->fieldPathPrefix() => $e->errors()['field']]);
}

if ($value === null) {
return null;
Expand Down