feat: ドメイン定数を追加し型をランタイム定義から導出#112
Conversation
| static isValid(value: string): boolean { | ||
| const normalized = value.trim().toUpperCase(); | ||
| return ( | ||
| StudentId.NUMERIC_ONLY.test(normalized) || | ||
| StudentId.ALPHANUMERIC.test(normalized) | ||
| ); | ||
| } |
There was a problem hiding this comment.
📝 Info: Double normalization in StudentId.isValid when called from validate()
The new isValid method at src/domain/shared/StudentId.ts:24 performs value.trim().toUpperCase() on its input. When called from validate() (line 36), this.value has already been normalized by fromString (line 32: value.trim().toUpperCase()). This means the normalization runs twice on the internal path. This is harmless but worth noting — the double normalization is the cost of making isValid a standalone public utility that can accept raw user input. This is a reasonable trade-off.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Pull request overview
コアドメイン側に、its-karte 等で重複していた定数・バリデーションを集約して export し、DRY を促進するPRです。
Changes:
StudentId.isValid()を追加し、学籍番号バリデーションの重複を解消- 相談者種別(student/teacher/staff/other)の表示名マッピング
clientTypeNamesを追加 - 後処理選択肢のランタイム配列
FOLLOW_UP_OPTIONSを追加
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/domain/shared/StudentId.ts | 学籍番号の静的バリデーション関数を公開し、validate() から再利用 |
| src/domain/aggregates/karte/FollowUp.ts | 後処理の選択肢一覧をランタイム配列として export |
| src/domain/aggregates/karte/Client.ts | 相談者種別の表示名マッピングを export |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** 学籍番号として妥当な文字列かを検証する */ | ||
| static isValid(value: string): boolean { | ||
| const normalized = value.trim().toUpperCase(); | ||
| return ( | ||
| StudentId.NUMERIC_ONLY.test(normalized) || |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| /** 後処理の選択肢一覧 */ | ||
| export const FOLLOW_UP_OPTIONS: readonly FollowUp[] = [ | ||
| "技術部", | ||
| "生協", | ||
| "情報基盤センター", |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
- FOLLOW_UP_OPTIONS: as const で定義し FollowUp 型を導出 - clientTypeNames: as const で定義し ClientType 型を導出 - StudentId.isValid(): 学籍番号のバリデーション関数を公開 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5fc1e9e to
adafdaa
Compare
- StudentId.isValidのテストケースを追加(正常系・異常系・正規化) - clientTypeNamesにsatisfies Record<Client["type"], string>を追加し Client型との同期をコンパイル時に保証 - clientTypeNamesの定義順序をClient型の後に移動 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
## Summary - Karte集約のドメインモデル、アプリケーション層(ユースケース)、インフラ層(Drizzleリポジトリ)を追加 - ConsultedAt型で日時精度(年/年月/日/日時)に対応 ## Dependencies このPRは以下がマージ済みであることを前提とします: - #111 大学組織構造の型をランタイム定義から導出する設計に変更 - #112 ドメイン定数を追加し型をランタイム定義から導出 ## What - **ドメイン層**: Karte集約(Karte, ConsultedAt, Assignee, SupportRecord, Consultation) - **アプリケーション層**: Create/Correct/Get/Import/List カルテユースケース - **インフラ層**: DrizzleKarteRepository、DBスキーマ(kartes, karte_assignees, karte_consultation_categories) - **ファクトリ**: createKarteUseCases ## Test plan - [ ] `npm run typecheck` が成功すること(依存PR マージ後) - [ ] `npm run test` が成功すること - [ ] Karteの作成・取得・一覧が動作すること 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/su-its/core/pull/103" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
StudentId.isValid(): 学籍番号の妥当性チェック関数を公開(private regexの重複解消)clientTypeNames: 相談者種別(student/teacher/staff/other)→表示名マッピングFOLLOW_UP_OPTIONS: 後処理の選択肢一覧をランタイム配列として公開Why
its-karteで同じ文字列リテラルやregexをローカルに再定義していた。
coreからexportすることでDRY違反を解消する。
Test plan
npm run typecheckが成功することStudentId.isValid("70312031")→ trueStudentId.isValid("invalid")→ false🤖 Generated with Claude Code