laravel/framework — pull request #2454 by simonhampel (2013-10-10 03:29:49+00:00)
Title: added call to UploadedFile::isValid to validateMax function

Failed uploads (specifically, files larger than PHP's file size limits), report zero size - not sure if this is a bug, or expected behaviour. This leads to incorrect success for this validation, `getSize` always reports 0 for a failed upload, so `validateMax` always succeeds for very large files.

This pull request fixes #2433

One question to be considered before merging this commit is whether the correct response to an invalid upload is to fail validations which assume you have a valid file. My argument is that uploading a 10MB file when PHP's limit is 8MB should _not_ result in validateMax succeeding.

Note that any other validations for files which rely on getSize (ie `validateMin`, `validateSize`, `validateBetween`), will all fail (correctly?) with a return value of zero, so this call to `isValid` is probably not required in those methods, other than perhaps to be overly cautious.

Another question is whether we should instead throw an exception when trying to validate a failed upload, thus making it obvious why the validation failed. This would both get around this problem of incorrect validation success, while also forcing the developer to check for a valid upload before validating the upload!? Not sure of the best approach there.