@@ -323,9 +323,10 @@ public static function validateFloat(IControl $control): bool
323
323
/**
324
324
* Is file size in limit?
325
325
*/
326
- public static function validateFileSize (Controls \ UploadControl $ control , $ limit ): bool
326
+ public static function validateFileSize (IControl $ control , $ limit ): bool
327
327
{
328
328
foreach (static ::toArray ($ control ->getValue ()) as $ file ) {
329
+ Validators::assert ($ file , Nette \Http \FileUpload::class, 'control value ' );
329
330
if ($ file ->getSize () > $ limit || $ file ->getError () === UPLOAD_ERR_INI_SIZE ) {
330
331
return false ;
331
332
}
@@ -338,10 +339,11 @@ public static function validateFileSize(Controls\UploadControl $control, $limit)
338
339
* Has file specified mime type?
339
340
* @param string|string[] $mimeType
340
341
*/
341
- public static function validateMimeType (Controls \ UploadControl $ control , $ mimeType ): bool
342
+ public static function validateMimeType (IControl $ control , $ mimeType ): bool
342
343
{
343
344
$ mimeTypes = is_array ($ mimeType ) ? $ mimeType : explode (', ' , $ mimeType );
344
345
foreach (static ::toArray ($ control ->getValue ()) as $ file ) {
346
+ Validators::assert ($ file , Nette \Http \FileUpload::class, 'control value ' );
345
347
$ type = strtolower ($ file ->getContentType ());
346
348
if (!in_array ($ type , $ mimeTypes , true ) && !in_array (preg_replace ('#/.*# ' , '/* ' , $ type ), $ mimeTypes , true )) {
347
349
return false ;
@@ -354,9 +356,10 @@ public static function validateMimeType(Controls\UploadControl $control, $mimeTy
354
356
/**
355
357
* Is file image?
356
358
*/
357
- public static function validateImage (Controls \ UploadControl $ control ): bool
359
+ public static function validateImage (IControl $ control ): bool
358
360
{
359
361
foreach (static ::toArray ($ control ->getValue ()) as $ file ) {
362
+ Validators::assert ($ file , Nette \Http \FileUpload::class, 'control value ' );
360
363
if (!$ file ->isImage ()) {
361
364
return false ;
362
365
}
0 commit comments