code: func (r *GormWorkItemRepository) CheckTypeAndSpaceShareTemplate(ctx context.Context, wit *WorkItemType, spaceID uuid.UUID) (bool, error) {
  	// Prohibit creation of work items from a base type.
  	if !wit.CanConstruct {
  		return false, errors.NewForbiddenError(fmt.Sprintf("cannot construct work items from %q (%s)", wit.Name, wit.ID))
  	}
  	var exists bool
  	// Prohibit creation of work items from a type that doesn't belong to current space template
  	query := fmt.Sprintf(`
  			SELECT EXISTS (
  				SELECT 1 from %[1]s WHERE id=$1 AND space_template_id = (
  					SELECT space_template_id FROM %[2]s WHERE id=$2
  				)
  			)`, wit.TableName(), space.Space{}.TableName())
  	err := r.db.Raw(query, wit.ID, spaceID).Row().Scan(&exists)
  	if err == nil && !exists {
  		return false, errors.NewBadParameterErrorFromString(
  			fmt.Sprintf("Workitem Type %q (ID: %s) does not belong to the current space template", wit.Name, wit.ID),
  		)
  	}
  	if err != nil {
  		log.Error(ctx, map[string]interface{}{
  			"space_id":         spaceID,
  			"workitem_type_id": wit.ID,
  			"err":              err,
  		}, "unable to fetch workitem types related to current space")
  		return false, errors.NewInternalError(ctx, errs.Wrapf(err, "unable to verify if %s exists", wit.ID))
  	}
  	return true, nil
  }
docs: // CheckTypeAndSpaceShareTemplate returns true if the given workitem type (wit)
  // belongs to the same space template as the space (spaceID); otherwise false is
  // returned