Skip to content

Make File size validation messages human-readable #802

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions