-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Description
Laravel Version
10.34.2
PHP Version
8.2.13
Database Driver & Version
N/A
Description
When using the validator with a manually passed Illuminate\Http\File object, the validation seems to work as expected. The getSize method checks for a Symfony file to determine on how to check that:
framework/src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Lines 2482 to 2484 in fb9d508
| } elseif ($value instanceof File) { | |
| return $value->getSize() / 1024; | |
| } |
But the returned error message is wrong, as it uses the string message. This seems to be due to the fact that the message formatter does an instanceof Illuminate\Http\UploadedFile:
framework/src/Illuminate/Validation/Concerns/FormatsMessages.php
Lines 225 to 227 in fb9d508
| } elseif ($this->getValue($attribute) instanceof UploadedFile) { | |
| return 'file'; | |
| } |
I'd expect to both use the same condition to determine on how to validate and on what message to use.
Steps To Reproduce
Example Snippet:
$v = \Illuminate\Support\Facades\Validator::make(
['file' => new \Illuminate\Http\File('composer.json')],
['file' => 'max:1']
);
dd($v->passes(), $v->messages()->all());