Commit 1471505
feat(validation): add upfront language code validation (Issue #3)
Fixed user experience issue where invalid language codes were only caught
during API calls, leading to cryptic error messages. Now validates all
language codes upfront before making any API requests.
Changes:
- Added VALID_LANGUAGES Set with all 30 supported DeepL language codes
- Added validateLanguageCodes() method to TranslateCommand class
- Validates single language codes (--to es)
- Validates multiple language codes (--to es,fr,de)
- Validates across all translation paths: text, file, directory, document
- Clear error messages list all valid language codes
- Empty strings after trimming are properly detected and rejected
- Added 6 comprehensive tests covering all validation scenarios
Benefits:
- Users get immediate, actionable feedback about invalid language codes
- Error messages include the full list of 30 valid codes for easy reference
- Prevents wasted API calls with invalid parameters
- Consistent validation across all translation workflows
- Better developer experience with early error detection
Test Coverage:
- All 1442 tests passing (100% pass rate)
- New tests: multi-language validation suite (6 tests)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 51a0129 commit 1471505
3 files changed
Lines changed: 141 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
19 | 30 | | |
20 | 31 | | |
21 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
19 | 26 | | |
20 | 27 | | |
21 | 28 | | |
| |||
71 | 78 | | |
72 | 79 | | |
73 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
74 | 94 | | |
75 | 95 | | |
76 | 96 | | |
| |||
207 | 227 | | |
208 | 228 | | |
209 | 229 | | |
210 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
211 | 237 | | |
212 | 238 | | |
213 | 239 | | |
| |||
227 | 253 | | |
228 | 254 | | |
229 | 255 | | |
230 | | - | |
| 256 | + | |
231 | 257 | | |
232 | 258 | | |
233 | 259 | | |
234 | | - | |
| 260 | + | |
235 | 261 | | |
236 | 262 | | |
237 | 263 | | |
| |||
269 | 295 | | |
270 | 296 | | |
271 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
272 | 301 | | |
273 | 302 | | |
274 | 303 | | |
| |||
317 | 346 | | |
318 | 347 | | |
319 | 348 | | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
320 | 352 | | |
321 | 353 | | |
322 | 354 | | |
| |||
429 | 461 | | |
430 | 462 | | |
431 | 463 | | |
432 | | - | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
433 | 471 | | |
434 | 472 | | |
435 | 473 | | |
| |||
461 | 499 | | |
462 | 500 | | |
463 | 501 | | |
464 | | - | |
| 502 | + | |
465 | 503 | | |
466 | 504 | | |
467 | 505 | | |
| |||
488 | 526 | | |
489 | 527 | | |
490 | 528 | | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
491 | 532 | | |
492 | 533 | | |
493 | 534 | | |
| |||
576 | 617 | | |
577 | 618 | | |
578 | 619 | | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
579 | 623 | | |
580 | 624 | | |
581 | 625 | | |
| |||
674 | 718 | | |
675 | 719 | | |
676 | 720 | | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
677 | 724 | | |
678 | 725 | | |
679 | 726 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1509 | 1509 | | |
1510 | 1510 | | |
1511 | 1511 | | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
1512 | 1590 | | |
0 commit comments