/** * @var FORM $form */ public function validate($form) { parent::validate($form); if ($this->continue_validating($form)) { $idx = 0; /** @var UPLOADED_FILE_SET $file_value */ $file_value = $this->_value; foreach ($file_value->files as $file) { if (!$file->is_valid()) { if ($this->required || $file->error != Uploaded_file_error_missing) { $form->record_error($this->id, $file->error_message(), $idx); } } else { if ($this->max_bytes && $file->size > $this->max_bytes) { $form->record_error($this->id, "{$this->caption} can be at most " . file_size_as_text($this->max_bytes) . '.', $idx); } } $idx += 1; } } }