parseNextColumns splits the columns string and validates each column name.
(columnsStr string)
| 377 | |
| 378 | // parseNextColumns splits the columns string and validates each column name. |
| 379 | func parseNextColumns(columnsStr string) ([]string, error) { |
| 380 | parts := strings.Split(columnsStr, ",") |
| 381 | columns := make([]string, 0, len(parts)) |
| 382 | for _, col := range parts { |
| 383 | col = strings.ToLower(strings.TrimSpace(col)) |
| 384 | if col == "" { |
| 385 | continue |
| 386 | } |
| 387 | if !slices.Contains(validNextColumns, col) { |
| 388 | return nil, invalidValueError("column", col, validNextColumns) |
| 389 | } |
| 390 | columns = append(columns, col) |
| 391 | } |
| 392 | if len(columns) == 0 { |
| 393 | return nil, fmt.Errorf("no valid columns specified") |
| 394 | } |
| 395 | return columns, nil |
| 396 | } |
| 397 | |
| 398 | // getNextColumnValue extracts the value for a column from a Recommendation. |
| 399 | func getNextColumnValue(rec *Recommendation, column string) string { |