test(api): align slug validation messaging#142
Conversation
|
Deployment failed with the following error: Learn More: https://vercel.com/hirokis-projects-afd618c7?upgradeToPro=build-rate-limit |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the API's slug validation logic and its corresponding test suite. It ensures that error messages for slug length are consistent with expected formatting and expands test coverage to explicitly validate the rejection of slugs that start or end with hyphens, improving the robustness of the validation process. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly aligns the slug validation messaging to use an en-dash and adds new tests for rejecting leading and trailing hyphens. The changes are good, but I have one suggestion to improve the user experience by providing a more specific error message for the newly tested validation case, ensuring it adheres to our English-only API error message standard.
📝 Walkthroughウォークスルースラッグ検証のエラーメッセージをハイフン(3-40文字)からエンダッシュ(3–40文字)に変更し、対応するテストケースを更新しました。先頭または末尾のハイフン拒否を検証する新しいテストも追加されています。 変更内容
コード評価の推定負荷🎯 1 (Trivial) | ⏱️ ~3分 詩
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Summary
Validation
Split out of #138 to keep this tiny validation tweak reviewable on its own.
Greptile Summary
このPRは
validateSlugのエラーメッセージを2点改善しています。①長さエラーのハイフン(-)をエンダッシュ(–)に統一、②先頭・末尾がハイフンのスラグに対して、従来は誤解を招く "character set" エラーを返していた箇所を専用メッセージ"slug must not start or end with a hyphen"に置き換え、それに対応するテストを追加しています。validation.ts:"slug must be 3-40 characters"→"slug must be 3–40 characters"(エンダッシュ統一)validation.ts:SLUG_REチェックの前にs.startsWith("-") || s.endsWith("-")の明示的ガードを追加し、より具体的なエラーメッセージを返すように修正validation.test.ts: 長さバリデーションのテスト期待値をエンダッシュに更新validation.test.ts:"rejects leading/trailing hyphens"テストを新規追加("-invalid"/"invalid-"の2ケース)SLUG_RE(/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/) は元々先頭・末尾ハイフンを拒否できていましたが、新しいチェックを前に置くことで より具体的なエラーメッセージ を提供できるようになっており、意図的かつ正しい設計変更です。チェックの順序・ロジックに問題はありません。Confidence Score: 5/5
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A([validateSlug 呼び出し]) --> B{typeof slug === 'string'?} B -- No --> E1["❌ 'slug is required'"] B -- Yes --> C[trim + toLowerCase] C --> D{length < 3 または > 40?} D -- Yes --> E2["❌ 'slug must be 3–40 characters'"] D -- No --> F{先頭または末尾が '-' ?} F -- Yes --> E3["❌ 'slug must not start or end with a hyphen' 🆕"] F -- No --> G{SLUG_RE に一致?} G -- No --> E4["❌ 'slug must contain only lowercase letters, numbers, and hyphens'"] G -- Yes --> H{'--' を含む?} H -- Yes --> E5["❌ 'slug must not contain consecutive hyphens'"] H -- No --> OK(["✅ null(有効)"]) style E3 fill:#d4edda,stroke:#28a745 style F fill:#d4edda,stroke:#28a745Last reviewed commit: ee7b03d