original_string: public function validate($data) {
          global $DB, $SITE;
          $cleaned = clean_param($data, PARAM_TEXT);
          if ($cleaned === '') {
              return get_string('required');
          }
          if ($this->name ==='shortname' &&
                  $DB->record_exists_sql('SELECT id from {course} WHERE shortname = ? AND id <> ?', array($data, $SITE->id))) {
              return get_string('shortnametaken', 'error', $data);
          }
          if ("$data" == "$cleaned") { // implicit conversion to string is needed to do exact comparison
              return true;
          } else {
              return get_string('validateerror', 'admin');
          }
      }
code: public function validate($data) {
          global $DB, $SITE;
          $cleaned = clean_param($data, PARAM_TEXT);
          if ($cleaned === '') {
              return get_string('required');
          }
          if ($this->name ==='shortname' &&
                  $DB->record_exists_sql('SELECT id from {course} WHERE shortname = ? AND id <> ?', array($data, $SITE->id))) {
              return get_string('shortnametaken', 'error', $data);
          }
          if ("$data" == "$cleaned") { // implicit conversion to string is needed to do exact comparison
              return true;
          } else {
              return get_string('validateerror', 'admin');
          }
      }
code_tokens: public function validate ( $ data ) { global $ DB , $ SITE ; $ cleaned = clean_param ( $ data , PARAM_TEXT ) ; if ( $ cleaned === '' ) { return get_string ( 'required' ) ; } if ( $ this -> name === 'shortname' && $ DB -> record_exists_sql ( 'SELECT id from {course} WHERE shortname = ? AND id <> ?' , array ( $ data , $ SITE -> id ) ) ) { return get_string ( 'shortnametaken' , 'error' , $ data ) ; } if ( "$data" == "$cleaned" ) { // implicit conversion to string is needed to do exact comparison return true ; } else { return get_string ( 'validateerror' , 'admin' ) ; } }
docstring: Validate the selected data
  
  @param string $data The selected value to validate
  @return mixed true or message string
docstring_tokens: Validate the selected data