Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 2.6.1 under development

- no changes in this release.
- Bug #802: Use translatable human-readable file sizes in `File` validation messages and add numeric, unit, and raw byte placeholders (@samdark)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Bug #802: Use translatable human-readable file sizes in `File` validation messages and add numeric, unit, and raw byte placeholders (@samdark)
- Chg #802: Use translatable human-readable file sizes in `File` validation messages and add numeric, unit, and raw byte placeholders (@samdark)


## 2.6.0 June 02, 2026

Expand Down
7 changes: 7 additions & 0 deletions docs/guide/en/built-in-rules-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ This option should be used with care because the client can send any media type
For filesystem-backed uploads, size checks use the actual file size on disk. For pathless streams, size checks use the
PSR-7 upload size when available. If a size constraint is configured and the size can't be determined, validation fails.

Default size error messages use translatable human-readable units, for example `50 MB` when `maxSize` is
`50 * 1024 * 1024`.
In custom messages, `{limit}` and `{exactly}` contain the full human-readable size string. Use `{limitValue}` /
`{exactlyValue}` with `{limitUnit}` / `{exactlyUnit}` when a custom message needs the numeric value and unit separately.
Use `{limitBytes}` or `{exactlyBytes}` when a custom message needs the raw byte value for ICU number or plural
formatting.

`size` is mutually exclusive with `minSize` and `maxSize`. When both `minSize` and `maxSize` are set, `minSize` must be
less than or equal to `maxSize`.

Expand Down
39 changes: 39 additions & 0 deletions messages/de/yii-validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Yiisoft\Validator\Rule\Each;
use Yiisoft\Validator\Rule\Email;
use Yiisoft\Validator\Rule\Equal;
use Yiisoft\Validator\Rule\File;
use Yiisoft\Validator\Rule\FilledAtLeast;
use Yiisoft\Validator\Rule\FilledOnlyOneOf;
use Yiisoft\Validator\Rule\GreaterThan;
Expand Down Expand Up @@ -211,6 +212,44 @@
/** @see AnyRule */
'At least one of the inner rules must pass the validation.' => 'Mindestens eine der inneren Regeln muss die Validierung bestehen.',

/** @see File */
'The size of {property} must be exactly {exactlyValue, number} {exactlyValue, plural, one{byte} other{bytes}}.' =>
'Die Größe von {property} muss genau {exactlyValue, number} {exactlyValue, plural, one{Byte} other{Byte}} betragen.',
'The size of {property} must be exactly {exactlyValue, number} KB.' =>
'Die Größe von {property} muss genau {exactlyValue, number} KB betragen.',
'The size of {property} must be exactly {exactlyValue, number} MB.' =>
'Die Größe von {property} muss genau {exactlyValue, number} MB betragen.',
'The size of {property} must be exactly {exactlyValue, number} GB.' =>
'Die Größe von {property} muss genau {exactlyValue, number} GB betragen.',
'The size of {property} must be exactly {exactlyValue, number} TB.' =>
'Die Größe von {property} muss genau {exactlyValue, number} TB betragen.',
'The size of {property} must be exactly {exactlyValue, number} PB.' =>
'Die Größe von {property} muss genau {exactlyValue, number} PB betragen.',
'The size of {property} cannot be smaller than {limitValue, number} {limitValue, plural, one{byte} other{bytes}}.' =>
'Die Größe von {property} darf nicht kleiner als {limitValue, number} {limitValue, plural, one{Byte} other{Byte}} sein.',
'The size of {property} cannot be smaller than {limitValue, number} KB.' =>
'Die Größe von {property} darf nicht kleiner als {limitValue, number} KB sein.',
'The size of {property} cannot be smaller than {limitValue, number} MB.' =>
'Die Größe von {property} darf nicht kleiner als {limitValue, number} MB sein.',
'The size of {property} cannot be smaller than {limitValue, number} GB.' =>
'Die Größe von {property} darf nicht kleiner als {limitValue, number} GB sein.',
'The size of {property} cannot be smaller than {limitValue, number} TB.' =>
'Die Größe von {property} darf nicht kleiner als {limitValue, number} TB sein.',
'The size of {property} cannot be smaller than {limitValue, number} PB.' =>
'Die Größe von {property} darf nicht kleiner als {limitValue, number} PB sein.',
'The size of {property} cannot be larger than {limitValue, number} {limitValue, plural, one{byte} other{bytes}}.' =>
'Die Größe von {property} darf nicht größer als {limitValue, number} {limitValue, plural, one{Byte} other{Byte}} sein.',
'The size of {property} cannot be larger than {limitValue, number} KB.' =>
'Die Größe von {property} darf nicht größer als {limitValue, number} KB sein.',
'The size of {property} cannot be larger than {limitValue, number} MB.' =>
'Die Größe von {property} darf nicht größer als {limitValue, number} MB sein.',
'The size of {property} cannot be larger than {limitValue, number} GB.' =>
'Die Größe von {property} darf nicht größer als {limitValue, number} GB sein.',
'The size of {property} cannot be larger than {limitValue, number} TB.' =>
'Die Größe von {property} darf nicht größer als {limitValue, number} TB sein.',
'The size of {property} cannot be larger than {limitValue, number} PB.' =>
'Die Größe von {property} darf nicht größer als {limitValue, number} PB sein.',

/** @see Image */
'{Property} must be an image.' => '{Property} muss ein Bild sein.',
'The width of {property} must be exactly {exactly, number} {exactly, plural, one{pixel} other{pixels}}.' =>
Expand Down
20 changes: 20 additions & 0 deletions messages/pl/yii-validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Yiisoft\Validator\Rule\Each;
use Yiisoft\Validator\Rule\Email;
use Yiisoft\Validator\Rule\Equal;
use Yiisoft\Validator\Rule\File;
use Yiisoft\Validator\Rule\GreaterThan;
use Yiisoft\Validator\Rule\GreaterThanOrEqual;
use Yiisoft\Validator\Rule\Image\Image;
Expand Down Expand Up @@ -63,6 +64,25 @@
'{Property} is not a valid email address.' => '{Property} nie jest prawidłowym adresem e-mail.',
/** @see FloatType */
'{Property} must be a float.' => '{Property} musi być liczbą zmiennoprzecinkową.',
/** @see File */
'The size of {property} must be exactly {exactlyValue, number} {exactlyValue, plural, one{byte} other{bytes}}.' => 'Rozmiar {property} musi wynosić dokładnie {exactlyValue, number} {exactlyValue, plural, one{bajt} few{bajty} many{bajtów} other{bajta}}.',
'The size of {property} must be exactly {exactlyValue, number} KB.' => 'Rozmiar {property} musi wynosić dokładnie {exactlyValue, number} KB.',
'The size of {property} must be exactly {exactlyValue, number} MB.' => 'Rozmiar {property} musi wynosić dokładnie {exactlyValue, number} MB.',
'The size of {property} must be exactly {exactlyValue, number} GB.' => 'Rozmiar {property} musi wynosić dokładnie {exactlyValue, number} GB.',
'The size of {property} must be exactly {exactlyValue, number} TB.' => 'Rozmiar {property} musi wynosić dokładnie {exactlyValue, number} TB.',
'The size of {property} must be exactly {exactlyValue, number} PB.' => 'Rozmiar {property} musi wynosić dokładnie {exactlyValue, number} PB.',
'The size of {property} cannot be smaller than {limitValue, number} {limitValue, plural, one{byte} other{bytes}}.' => 'Rozmiar {property} nie może być mniejszy niż {limitValue, number} {limitValue, plural, one{bajt} few{bajty} many{bajtów} other{bajta}}.',
'The size of {property} cannot be smaller than {limitValue, number} KB.' => 'Rozmiar {property} nie może być mniejszy niż {limitValue, number} KB.',
'The size of {property} cannot be smaller than {limitValue, number} MB.' => 'Rozmiar {property} nie może być mniejszy niż {limitValue, number} MB.',
'The size of {property} cannot be smaller than {limitValue, number} GB.' => 'Rozmiar {property} nie może być mniejszy niż {limitValue, number} GB.',
'The size of {property} cannot be smaller than {limitValue, number} TB.' => 'Rozmiar {property} nie może być mniejszy niż {limitValue, number} TB.',
'The size of {property} cannot be smaller than {limitValue, number} PB.' => 'Rozmiar {property} nie może być mniejszy niż {limitValue, number} PB.',
'The size of {property} cannot be larger than {limitValue, number} {limitValue, plural, one{byte} other{bytes}}.' => 'Rozmiar {property} nie może być większy niż {limitValue, number} {limitValue, plural, one{bajt} few{bajty} many{bajtów} other{bajta}}.',
'The size of {property} cannot be larger than {limitValue, number} KB.' => 'Rozmiar {property} nie może być większy niż {limitValue, number} KB.',
'The size of {property} cannot be larger than {limitValue, number} MB.' => 'Rozmiar {property} nie może być większy niż {limitValue, number} MB.',
'The size of {property} cannot be larger than {limitValue, number} GB.' => 'Rozmiar {property} nie może być większy niż {limitValue, number} GB.',
'The size of {property} cannot be larger than {limitValue, number} TB.' => 'Rozmiar {property} nie może być większy niż {limitValue, number} TB.',
'The size of {property} cannot be larger than {limitValue, number} PB.' => 'Rozmiar {property} nie może być większy niż {limitValue, number} PB.',
/** @see Image */
'{Property} must be an image.' => '{Property} musi być obrazem.',
'The width of {property} must be exactly {exactly, number} {exactly, plural, one{pixel} other{pixels}}.' => 'Szerokość {property} musi wynosić dokładnie {exactly, number} {exactly, plural, one{piksel} few{piksele} many{pikseli} other{piksela}}.',
Expand Down
39 changes: 39 additions & 0 deletions messages/pt-BR/yii-validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Yiisoft\Validator\Rule\Each;
use Yiisoft\Validator\Rule\Email;
use Yiisoft\Validator\Rule\Equal;
use Yiisoft\Validator\Rule\File;
use Yiisoft\Validator\Rule\FilledAtLeast;
use Yiisoft\Validator\Rule\FilledOnlyOneOf;
use Yiisoft\Validator\Rule\GreaterThan;
Expand Down Expand Up @@ -188,6 +189,44 @@
/** @see AnyRule */
'At least one of the inner rules must pass the validation.' => 'Pelo menos uma das regras internas deve passar na validação.',

/** @see File */
'The size of {property} must be exactly {exactlyValue, number} {exactlyValue, plural, one{byte} other{bytes}}.' =>
'O tamanho de {property} deve ser exatamente {exactlyValue, number} {exactlyValue, plural, one{byte} few{bytes} many{bytes} other{bytes}}.',
'The size of {property} must be exactly {exactlyValue, number} KB.' =>
'O tamanho de {property} deve ser exatamente {exactlyValue, number} KB.',
'The size of {property} must be exactly {exactlyValue, number} MB.' =>
'O tamanho de {property} deve ser exatamente {exactlyValue, number} MB.',
'The size of {property} must be exactly {exactlyValue, number} GB.' =>
'O tamanho de {property} deve ser exatamente {exactlyValue, number} GB.',
'The size of {property} must be exactly {exactlyValue, number} TB.' =>
'O tamanho de {property} deve ser exatamente {exactlyValue, number} TB.',
'The size of {property} must be exactly {exactlyValue, number} PB.' =>
'O tamanho de {property} deve ser exatamente {exactlyValue, number} PB.',
'The size of {property} cannot be smaller than {limitValue, number} {limitValue, plural, one{byte} other{bytes}}.' =>
'O tamanho de {property} não pode ser menor que {limitValue, number} {limitValue, plural, one{byte} few{bytes} many{bytes} other{bytes}}.',
'The size of {property} cannot be smaller than {limitValue, number} KB.' =>
'O tamanho de {property} não pode ser menor que {limitValue, number} KB.',
'The size of {property} cannot be smaller than {limitValue, number} MB.' =>
'O tamanho de {property} não pode ser menor que {limitValue, number} MB.',
'The size of {property} cannot be smaller than {limitValue, number} GB.' =>
'O tamanho de {property} não pode ser menor que {limitValue, number} GB.',
'The size of {property} cannot be smaller than {limitValue, number} TB.' =>
'O tamanho de {property} não pode ser menor que {limitValue, number} TB.',
'The size of {property} cannot be smaller than {limitValue, number} PB.' =>
'O tamanho de {property} não pode ser menor que {limitValue, number} PB.',
'The size of {property} cannot be larger than {limitValue, number} {limitValue, plural, one{byte} other{bytes}}.' =>
'O tamanho de {property} não pode ser maior que {limitValue, number} {limitValue, plural, one{byte} few{bytes} many{bytes} other{bytes}}.',
'The size of {property} cannot be larger than {limitValue, number} KB.' =>
'O tamanho de {property} não pode ser maior que {limitValue, number} KB.',
'The size of {property} cannot be larger than {limitValue, number} MB.' =>
'O tamanho de {property} não pode ser maior que {limitValue, number} MB.',
'The size of {property} cannot be larger than {limitValue, number} GB.' =>
'O tamanho de {property} não pode ser maior que {limitValue, number} GB.',
'The size of {property} cannot be larger than {limitValue, number} TB.' =>
'O tamanho de {property} não pode ser maior que {limitValue, number} TB.',
'The size of {property} cannot be larger than {limitValue, number} PB.' =>
'O tamanho de {property} não pode ser maior que {limitValue, number} PB.',

/** @see Image */
'{Property} must be an image.' => '{Property} deve ser uma imagem.',
'The width of {property} must be exactly {exactly, number} {exactly, plural, one{pixel} other{pixels}}.' =>
Expand Down
39 changes: 39 additions & 0 deletions messages/ru/yii-validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Yiisoft\Validator\Rule\Each;
use Yiisoft\Validator\Rule\Email;
use Yiisoft\Validator\Rule\Equal;
use Yiisoft\Validator\Rule\File;
use Yiisoft\Validator\Rule\FilledAtLeast;
use Yiisoft\Validator\Rule\FilledOnlyOneOf;
use Yiisoft\Validator\Rule\GreaterThan;
Expand Down Expand Up @@ -196,6 +197,44 @@
/** @see AnyRule */
'At least one of the inner rules must pass the validation.' => 'Как минимум одно из внутренних правил должно пройти валидацию.',

/** @see File */
'The size of {property} must be exactly {exactlyValue, number} {exactlyValue, plural, one{byte} other{bytes}}.' =>
'Размер {property} должен быть ровно {exactlyValue, number} {exactlyValue, plural, one{байт} few{байта} many{байтов} other{байта}}.',
'The size of {property} must be exactly {exactlyValue, number} KB.' =>
'Размер {property} должен быть ровно {exactlyValue, number} КБ.',
'The size of {property} must be exactly {exactlyValue, number} MB.' =>
'Размер {property} должен быть ровно {exactlyValue, number} МБ.',
'The size of {property} must be exactly {exactlyValue, number} GB.' =>
'Размер {property} должен быть ровно {exactlyValue, number} ГБ.',
'The size of {property} must be exactly {exactlyValue, number} TB.' =>
'Размер {property} должен быть ровно {exactlyValue, number} ТБ.',
'The size of {property} must be exactly {exactlyValue, number} PB.' =>
'Размер {property} должен быть ровно {exactlyValue, number} ПБ.',
'The size of {property} cannot be smaller than {limitValue, number} {limitValue, plural, one{byte} other{bytes}}.' =>
'Размер {property} не может быть меньше {limitValue, number} {limitValue, plural, one{байта} few{байтов} many{байтов} other{байта}}.',
'The size of {property} cannot be smaller than {limitValue, number} KB.' =>
'Размер {property} не может быть меньше {limitValue, number} КБ.',
'The size of {property} cannot be smaller than {limitValue, number} MB.' =>
'Размер {property} не может быть меньше {limitValue, number} МБ.',
'The size of {property} cannot be smaller than {limitValue, number} GB.' =>
'Размер {property} не может быть меньше {limitValue, number} ГБ.',
'The size of {property} cannot be smaller than {limitValue, number} TB.' =>
'Размер {property} не может быть меньше {limitValue, number} ТБ.',
'The size of {property} cannot be smaller than {limitValue, number} PB.' =>
'Размер {property} не может быть меньше {limitValue, number} ПБ.',
'The size of {property} cannot be larger than {limitValue, number} {limitValue, plural, one{byte} other{bytes}}.' =>
'Размер {property} не может быть больше {limitValue, number} {limitValue, plural, one{байта} few{байтов} many{байтов} other{байта}}.',
'The size of {property} cannot be larger than {limitValue, number} KB.' =>
'Размер {property} не может быть больше {limitValue, number} КБ.',
'The size of {property} cannot be larger than {limitValue, number} MB.' =>
'Размер {property} не может быть больше {limitValue, number} МБ.',
'The size of {property} cannot be larger than {limitValue, number} GB.' =>
'Размер {property} не может быть больше {limitValue, number} ГБ.',
'The size of {property} cannot be larger than {limitValue, number} TB.' =>
'Размер {property} не может быть больше {limitValue, number} ТБ.',
'The size of {property} cannot be larger than {limitValue, number} PB.' =>
'Размер {property} не может быть больше {limitValue, number} ПБ.',

/** @see Image */
'{Property} must be an image.' => '{Property} должно быть изображением.',
'The width of {property} must be exactly {exactly, number} {exactly, plural, one{pixel} other{pixels}}.' =>
Expand Down
Loading
Loading