Skip to content

Commit

Permalink
[11.x] fix the method explodeExplicitRule to support Customizab…
Browse files Browse the repository at this point in the history
…le Date Validation (#54353)

* fix Date Validation rules

* fix Date Validation rules

* styleci

---------

Co-authored-by: cuong.tt <[email protected]>
  • Loading branch information
mrvipchien and cuong.tt authored Jan 27, 2025
1 parent 48bdc07 commit b7fca4b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/Illuminate/Validation/ValidationRuleParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules\Date;
use Illuminate\Validation\Rules\Exists;
use Illuminate\Validation\Rules\Unique;

Expand Down Expand Up @@ -95,11 +96,17 @@ protected function explodeExplicitRule($rule, $attribute)
return Arr::wrap($this->prepareRule($rule, $attribute));
}

return array_map(
[$this, 'prepareRule'],
$rule,
array_fill((int) array_key_first($rule), count($rule), $attribute)
);
$rules = [];

foreach ($rule as $value) {
if ($value instanceof Date) {
$rules = array_merge($rules, explode('|', (string) $value));
} else {
$rules[] = $this->prepareRule($value, $attribute);
}
}

return $rules;
}

/**
Expand Down

0 comments on commit b7fca4b

Please sign in to comment.