protected function extra_validation($data, $files, array &$errors) {
        $overrides = $this->get_role_overrides_from_data($data);

        // Check role overrides to ensure that:
        // - roles are unique; and
        // - specifeid retention periods are numeric.
        $seenroleids = [];
        foreach ($overrides as $id => $override) {
            $override->purposeid = 0;
            $persistent = new \tool_dataprivacy\purpose_override($override->id, $override);

            if (isset($seenroleids[$persistent->get('roleid')])) {
                $errors["roleoverride_roleid[{$id}]"] = get_string('duplicaterole');
            }
            $seenroleids[$persistent->get('roleid')] = true;

            $errors = array_merge($errors, $persistent->get_errors());
        }

        return $errors;
    }