-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validation rule Form::PATTERN for Nette\Http\FileUpload #130
Comments
Feel free to make addUpload() and PATTERN work together. But for consistency you should write |
I am sorry if my issue written aggressively. Still does not work. require __DIR__ . '/vendor/autoload.php';
$form = new \Nette\Forms\Form();
$form->addUpload('csv')
->setRequired(false)
// next line does not work
->addRule($form::PATTERN, 'File is not csv.', '.*\.csv');
$form->addSubmit('foo');
$form->onSuccess[] = function ($form, $values) {
dump($values);die();
};
echo $form; save this like foo.csv and try upload
In content of If you change pattern for match tmp path, than upload is correct
|
I understand that it doesn't work, as I said, feel free to fix it. But consider, that PATTERN is used for regular expressions, so it may be confusing to use it for wildcards. |
Ok. Second way, I can add condition to Validator::validatePattern, where check instance of FileUpload and call |
Description
Hi,
i have use case
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.
The text was updated successfully, but these errors were encountered: