original_string: public function validation($data, $files) {
          global $DB;
          $errors = parent::validation($data, $files);
          if (!empty($data['idnumber'])) {
              if ($existing = $DB->get_record('course_categories', array('idnumber' => $data['idnumber']))) {
                  if (!$data['id'] || $existing->id != $data['id']) {
                      $errors['idnumber'] = get_string('categoryidnumbertaken', 'error');
                  }
              }
          }
          return $errors;
      }
code: public function validation($data, $files) {
          global $DB;
          $errors = parent::validation($data, $files);
          if (!empty($data['idnumber'])) {
              if ($existing = $DB->get_record('course_categories', array('idnumber' => $data['idnumber']))) {
                  if (!$data['id'] || $existing->id != $data['id']) {
                      $errors['idnumber'] = get_string('categoryidnumbertaken', 'error');
                  }
              }
          }
          return $errors;
      }
code_tokens: public function validation ( $ data , $ files ) { global $ DB ; $ errors = parent :: validation ( $ data , $ files ) ; if ( ! empty ( $ data [ 'idnumber' ] ) ) { if ( $ existing = $ DB -> get_record ( 'course_categories' , array ( 'idnumber' => $ data [ 'idnumber' ] ) ) ) { if ( ! $ data [ 'id' ] || $ existing -> id != $ data [ 'id' ] ) { $ errors [ 'idnumber' ] = get_string ( 'categoryidnumbertaken' , 'error' ) ; } } } return $ errors ; }
docstring: Validates the data submit for this form.
  
  @param array $data An array of key,value data pairs.
  @param array $files Any files that may have been submit as well.
  @return array An array of errors.
docstring_tokens: Validates the data submit for this form .