protected function validate_path($value) {

        // The last item should be the parent ID.
        $id = $this->get('parentid');
        if (substr($value, -(strlen($id) + 2)) != '/' . $id . '/') {
            return new lang_string('invaliddata', 'error');

        } else if (!preg_match('@/([0-9]+/)+@', $value)) {
            // The format of the path is not correct.
            return new lang_string('invaliddata', 'error');
        }

        return true;
    }