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.');
        }
    }
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.');
        }
    }
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.' ) ; } }
custom validations.

@throws \coding_exception when validation fails.
@return void
custom validations .