How to validate file using hook_file_validate? I want to validate my file, I'm using 


  hook_file_validate


function test_file_validate($file) {
  $errors = array();

  if (empty($file-&gt;filename)) {
    $errors[] = t("The file's name is empty. Please give a name to the file.");
  }
  if (retstrlen($file-&gt;filename) &gt; 255) {
    $errors[] = t("The file's name exceeds the 255 characters limit. Please rename the file and try again.");
  }
  return $errors;
}


But, when I am going to print_r($file) I am not getting any values, please let know how to use this function
In Drupal 7 just use drupal_set_message

/**
 * Implementing hook_file_validate
 * @param type $file : Object
 * @return type : array of error messages
 */
function hook_file_validate($file) {
    drupal_set_message("&lt;pre&gt;" . print_r($file, 1) . "&lt;/pre&gt;");
    $errors = array();
    if ($file-&gt;source == 'field_article_file_und_0') {
        if ($file-&gt;filesize &gt; 290081) {
            $errors[] = t("The file's exceeds upload limit. Please try again.");
        }
    }
    return $errors;
}