| 33 | |
| 34 | // ─── Validation ────────────────────────────────────────────────────── |
| 35 | function validatePRConfig(templates: PRTemplate[]): string | null { |
| 36 | if (templates.length === 0) return 'No pull requests to create. Generate them first.'; |
| 37 | if (templates.length > MAX_ITEMS) return `Maximum ${MAX_ITEMS} PRs allowed.`; |
| 38 | const branchNames = new Set<string>(); |
| 39 | for (const pr of templates) { |
| 40 | if (branchNames.has(pr.branchName)) return `Duplicate branch name: "${pr.branchName}".`; |
| 41 | branchNames.add(pr.branchName); |
| 42 | } |
| 43 | return null; |
| 44 | } |
| 45 | |
| 46 | function validatePairConfig(coAuthors: CoAuthor[], templates: PairTemplate[]): string | null { |
| 47 | const validCoAuthors = coAuthors.filter(ca => ca.name.trim() && ca.email.trim()); |