Skip to content

[Validator] Support "maxSize" given in KiB #10962

Closed
@webmozart

Description

@webmozart

The File constraint should support the following notations for the "maxSize" option:

new File(array('maxSize' => 1234)); // bytes
new File(array('maxSize' => '2k')); // kilobytes (case insensitive)
new File(array('maxSize' => '2ki')); // kibibytes (case insensitive)
new File(array('maxSize' => '1m')); // megabytes (case insensitive)
new File(array('maxSize' => '1mi')); // mebibytes (case insensitive)

// etc.

The conversion of the passed value to the number of bytes should be done already in the constructor of File, to simplify dealing with the file constraint:

$constraint = new File(array('maxSize' => '1ki'));

assert 1024 === $constraint->maxSize;

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureGood first issueIdeal for your first contribution! (some Symfony experience may be required)Validator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions