mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
refactored file validator.
This commit is contained in:
@ -167,7 +167,7 @@ class FileValidator extends Validator
|
||||
protected function validateValue($file)
|
||||
{
|
||||
if (!$file instanceof UploadedFile || $file->error == UPLOAD_ERR_NO_FILE) {
|
||||
return $this->skipOnEmpty ? null : [$this->uploadRequired, []];
|
||||
return [$this->uploadRequired, []];
|
||||
}
|
||||
switch ($file->error) {
|
||||
case UPLOAD_ERR_OK:
|
||||
@ -224,6 +224,14 @@ class FileValidator extends Validator
|
||||
return $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function isEmpty($value, $trim = false)
|
||||
{
|
||||
return !$value instanceof UploadedFile || $value->error == UPLOAD_ERR_NO_FILE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts php.ini style size to bytes
|
||||
*
|
||||
|
Reference in New Issue
Block a user