8000 [11.x] fix the method ```explodeExplicitRule``` to support Customiza… · laravel/framework@b7fca4b · GitHub < 8000 meta name="color-scheme" content="light dark" />
[go: up one dir, main page]

Skip to content

Commit b7fca4b

Browse files
mrvipchiencuong.tt
andauthored
[11.x] fix the method explodeExplicitRule to support Customizable Date Validation (#54353)
* fix Date Validation rules * fix Date Validation rules * styleci --------- Co-authored-by: cuong.tt <cuong.tt@gmail.com>
1 parent 48bdc07 commit b7fca4b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/Illuminate/Validation/ValidationRuleParser.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Illuminate\Support\Arr;
1010
use Illuminate\Support\Collection;
1111
use Illuminate\Support\Str;
12+
use Illuminate\Validation\Rules\Date;
1213
use Illuminate\Validation\Rules\Exists;
1314
use Illuminate\Validation\Rules\Unique;
1415

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

98-
return array_map(
99-
[$this, 'prepareRule'],
100-
$rule,
101-
array_fill((int) array_key_first($rule), count($rule), $attribute)
102-
);
99+
$rules = [];
100+
101+
foreach ($rule as $value) {
102+
if ($value instanceof Date) {
103+
$rules = array_merge($rules, explode('|', (string) $value));
104+
} else {
105+
$rules[] = $this->prepareRule($value, $attribute);
106+
}
107+
}
108+
109+
return $rules;
103110
}
104111

105112
/**

0 commit comments

Comments
 (0)
0