Skip to content

feat: ドメイン定数を追加し型をランタイム定義から導出#112

Merged
KinjiKawaguchi merged 2 commits intodevelopfrom
feat/domain-constants
Mar 24, 2026
Merged

feat: ドメイン定数を追加し型をランタイム定義から導出#112
KinjiKawaguchi merged 2 commits intodevelopfrom
feat/domain-constants

Conversation

@KinjiKawaguchi
Copy link
Copy Markdown
Member

@KinjiKawaguchi KinjiKawaguchi commented Mar 24, 2026

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") → true
  • StudentId.isValid("invalid") → false

🤖 Generated with Claude Code


Open with Devin

Copilot AI review requested due to automatic review settings March 24, 2026 03:54
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Open in Devin Review

Comment on lines +23 to +29
static isValid(value: string): boolean {
const normalized = value.trim().toUpperCase();
return (
StudentId.NUMERIC_ONLY.test(normalized) ||
StudentId.ALPHANUMERIC.test(normalized)
);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 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.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/domain/aggregates/karte/FollowUp.ts Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +22 to +26
/** 学籍番号として妥当な文字列かを検証する */
static isValid(value: string): boolean {
const normalized = value.trim().toUpperCase();
return (
StudentId.NUMERIC_ONLY.test(normalized) ||

This comment was marked as resolved.

Comment on lines +9 to +13
/** 後処理の選択肢一覧 */
export const FOLLOW_UP_OPTIONS: readonly FollowUp[] = [
"技術部",
"生協",
"情報基盤センター",

This comment was marked as resolved.

- FOLLOW_UP_OPTIONS: as const で定義し FollowUp 型を導出
- clientTypeNames: as const で定義し ClientType 型を導出
- StudentId.isValid(): 学籍番号のバリデーション関数を公開

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@KinjiKawaguchi KinjiKawaguchi force-pushed the feat/domain-constants branch from 5fc1e9e to adafdaa Compare March 24, 2026 04:00
@KinjiKawaguchi KinjiKawaguchi changed the title feat: ドメイン定数・バリデーション関数を追加 feat: ドメイン定数を追加し型をランタイム定義から導出 Mar 24, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

- StudentId.isValidのテストケースを追加(正常系・異常系・正規化)
- clientTypeNamesにsatisfies Record<Client["type"], string>を追加し
  Client型との同期をコンパイル時に保証
- clientTypeNamesの定義順序をClient型の後に移動

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@KinjiKawaguchi KinjiKawaguchi merged commit 95c5cfe into develop Mar 24, 2026
4 checks passed
@KinjiKawaguchi KinjiKawaguchi deleted the feat/domain-constants branch March 24, 2026 04:22
KinjiKawaguchi added a commit that referenced this pull request Mar 24, 2026
## 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants