original_string: protected function validate_data() {
          parent::validate_data();
          if ($this->contextlevel != CONTEXT_COURSE) {
              throw new \coding_exception('Context level must be CONTEXT_COURSE.');
          }
  
          if (!isset($this->relateduserid)) {
              throw new \coding_exception('The \'relateduserid\' must be set.');
          }
      }
code: protected function validate_data() {
          parent::validate_data();
          if ($this->contextlevel != CONTEXT_COURSE) {
              throw new \coding_exception('Context level must be CONTEXT_COURSE.');
          }
  
          if (!isset($this->relateduserid)) {
              throw new \coding_exception('The \'relateduserid\' must be set.');
          }
      }
code_tokens: protected function validate_data ( ) { parent :: validate_data ( ) ; if ( $ this -> contextlevel != CONTEXT_COURSE ) { throw new \ coding_exception ( 'Context level must be CONTEXT_COURSE.' ) ; } if ( ! isset ( $ this -> relateduserid ) ) { throw new \ coding_exception ( 'The \'relateduserid\' must be set.' ) ; } }
docstring: custom validations.
  
  @throws \coding_exception when validation fails.
  @return void
docstring_tokens: custom validations .