Skip to content

Validation rule Form::PATTERN for Nette\Http\FileUpload  #130

@h4kuna

Description

@h4kuna
  • bug report? yes
  • feature request? no
  • version: 2.4

Description

Hi,
i have use case

$form->addUpload('csv')
    ->addRule($form::MIME_TYPE, 'Foo', 'text/*')
    // next line does not work
    ->addRule($form::PATTERN, 'Message', '*.csv');

I found in Validator::validatePattern where first parameter is (IControl)->getValue(). It's ok. If i look at (FileUploadControl)->getValue() you get FileUpload and method __toString return tmpName. Where is problem? I don't need run validation on temporary name, but on original name.

For first validation check extension of file. Please you don't write, this valid is not relevant. I can't use PATTERN validation for this moment.

Or throw exception, this rule is not relevant for FileUpload. Because here is wtf behavior.

I understant if you change return value in method __toString(), it can be BC break or anything worse.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions