public function validate() {
        foreach ($this->requiredfields as $key) {
            if (empty($this->{$key})) {
                throw new portfolio_format_leap2a_exception('leap2a_missingfield', 'portfolio', '', $key);
            }
        }
        if ($this->type == 'selection') {
            if (count($this->links) == 0) {
                throw new portfolio_format_leap2a_exception('leap2a_emptyselection', 'portfolio');
            }
            //TODO make sure we have a category with a scheme 'selection_type'
        }
    }