FileValidator: updated guide-ru,en, PHP; updated tests

This commit is contained in:
SilverFire - Dmitry Naumenko
2016-02-24 09:05:29 +02:00
parent 2201bf14e2
commit 66c6268e5f
4 changed files with 10 additions and 5 deletions

View File

@ -240,7 +240,10 @@ function foo($model, $attribute) {
допустимы. допустимы.
- `mimeTypes`: список MIME-типов, которые допустимы для загрузки. Это может быть или массив, или строка, - `mimeTypes`: список MIME-типов, которые допустимы для загрузки. Это может быть или массив, или строка,
содержащая MIME-типы файлов, разделенные пробелом или запятой (пример: "image/jpeg, image/png"). содержащая MIME-типы файлов, разделенные пробелом или запятой (пример: "image/jpeg, image/png").
Имена mime-типов не чувствительны к регистру. По умолчанию - null, что значит, что допустимы все MIME-типы. В именах MIME-типов допустимо использовать символ `*` для выбора группы mime-типов.
Например, `image/*` разрешит все типы, которы начинаются с `image/` (пример: `image/jpeg`, `image/png`).
Имена MIME-типов не чувствительны к регистру. По умолчанию - null, что значит, что допустимы все MIME-типы.
Более детальную информацию можно найти в [списке MIME-типов](https://ru.wikipedia.org/wiki/Список_MIME-типов).
- `minSize`: минимальный размер файла в байтах, разрешенный для загрузки. По умолчанию - null, что значит, что нет - `minSize`: минимальный размер файла в байтах, разрешенный для загрузки. По умолчанию - null, что значит, что нет
минимального лимита. минимального лимита.
- `maxSize`: максимальный размер файла в байтах, разрешенный для загрузки. По умолчанию - null, что значит, что нет - `maxSize`: максимальный размер файла в байтах, разрешенный для загрузки. По умолчанию - null, что значит, что нет

View File

@ -294,6 +294,8 @@ This validator checks if the input is a valid uploaded file.
extensions are allowed. extensions are allowed.
- `mimeTypes`: a list of file MIME types that are allowed to be uploaded. This can be either an array - `mimeTypes`: a list of file MIME types that are allowed to be uploaded. This can be either an array
or a string consisting of file MIME types separated by space or comma (e.g. "image/jpeg, image/png"). or a string consisting of file MIME types separated by space or comma (e.g. "image/jpeg, image/png").
The wildcard mask with the special character `*` can be used to match groups of mime types.
For example `image/*` will pass all mime types, that begin with `image/` (e.g. `image/jpeg`, `image/png`).
Mime type names are case-insensitive. Defaults to null, meaning all MIME types are allowed. Mime type names are case-insensitive. Defaults to null, meaning all MIME types are allowed.
For more details, please refer to [common media types](http://en.wikipedia.org/wiki/Internet_media_type#List_of_common_media_types). For more details, please refer to [common media types](http://en.wikipedia.org/wiki/Internet_media_type#List_of_common_media_types).
- `minSize`: the minimum number of bytes required for the uploaded file. Defaults to null, meaning no lower limit. - `minSize`: the minimum number of bytes required for the uploaded file. Defaults to null, meaning no lower limit.

View File

@ -44,10 +44,9 @@ class FileValidator extends Validator
* @var array|string a list of file MIME types that are allowed to be uploaded. * @var array|string a list of file MIME types that are allowed to be uploaded.
* This can be either an array or a string consisting of file MIME types * This can be either an array or a string consisting of file MIME types
* separated by space or comma (e.g. "text/plain, image/png"). * separated by space or comma (e.g. "text/plain, image/png").
* Mime type names are case-insensitive. Defaults to null, meaning all MIME types * The mask with the special character `*` can be used to match groups of mime types.
* are allowed. * For example `image/*` will pass all mime types, that begin with `image/` (e.g. `image/jpeg`, `image/png`).
* The wildcard mask with the special character `*` can be used to match groups of mime types. * Mime type names are case-insensitive. Defaults to null, meaning all MIME types are allowed.
* For example `image/*` will pass all mime types, that begin with `image/` (e.g. `image/jpeg`, `image/png`)
* @see wrongMimeType for the customized message for wrong MIME type. * @see wrongMimeType for the customized message for wrong MIME type.
*/ */
public $mimeTypes; public $mimeTypes;

View File

@ -375,6 +375,7 @@ class FileValidatorTest extends TestCase
return [ return [
['test.jpg', 'image/*'], ['test.jpg', 'image/*'],
['test.png', 'image/*'], ['test.png', 'image/*'],
['test.png', 'IMAGE/*'],
['test.txt', 'text/*'], ['test.txt', 'text/*'],
['test.xml', '*/xml'], ['test.xml', '*/xml'],
['test.odt', 'application/vnd*'] ['test.odt', 'application/vnd*']