Skip to content

Make File size validation messages human-readable #802

@samdark

Description

@samdark

Yiisoft\Validator\Rule\File size validation placeholders currently expose raw byte counts.

Example:

new File(
    maxSize: 50 * 1024 * 1024,
    tooBigMessage: "{file} is larger than {limit}.",
)

{limit} resolves to 52428800, which is not convenient for user-facing upload validation messages.

Preferred behavior: use the same existing placeholders, but format size values in a human-readable way:

  • {limit} -> 50 MB
  • {exactly} -> 50 MB

This would let applications use Yii Validator defaults/placeholders without duplicating byte-to-readable-size formatting in application code.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions