Skip to content

Commit 6f5af71

Browse files
anderssvclaude
andcommitted
Add kotlin-sum-types skill for parse-don't-validate pattern
Created new skill documenting the sealed classes pattern for type-safe validation using the "parse, don't validate" principle. What it teaches: - Sealed classes for valid/invalid state representation - @JsonCreator integration with Jackson for parsing - Composable validation (Email → Address → RegistrationForm) - Error collection with field paths - Type-safe guarantees - invalid states unrepresentable in domain logic - Controller pattern using when expressions Based on working examples: - src/main/kotlin/user/registration/RegistrationDomain.kt - src/test/kotlin/user/registration/ParsingTest.kt This pattern pushes validation to system boundaries and lets domain code operate only on validated types, leveraging Kotlin's type system for safety. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent a5be306 commit 6f5af71

3 files changed

Lines changed: 473 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ If you're looking for the workshop, you can [find it here](doc/workshop/README.m
3636

3737
This repository includes reusable [Claude Code skills](skills/README.md) that teach Claude the patterns and practices used here:
3838

39+
- **kotlin-sum-types** 🔀 - Parse, don't validate with sealed classes for type-safe validation
3940
- **kotlin-tdd** 🧪 - Test-Driven Development with fakes, object mothers, and Testing Through The Domain
4041
- **kotlin-context-di** 🔌 - Manual dependency injection using SystemContext and TestContext patterns
4142

skills/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,29 @@ npx skills add anderssv/the-example/skills
1212

1313
## Available Skills
1414

15+
### 🔀 kotlin-sum-types
16+
17+
Parse, don't validate - using sealed classes for type-safe validation and state representation.
18+
19+
**Location:** `domain/kotlin-sum-types/`
20+
21+
**What it teaches:**
22+
- Sealed classes for representing valid/invalid states
23+
- Parse don't validate principle
24+
- Type-safe validation at boundaries
25+
- Composable validation (Email → Address → RegistrationForm)
26+
- Jackson integration with @JsonCreator
27+
- Error collection with paths
28+
- Making invalid states unrepresentable
29+
- Controller pattern for handling valid/invalid cases
30+
31+
**Use when:**
32+
- Parsing external input (JSON, CSV, user forms)
33+
- Need to collect multiple validation errors
34+
- Want type-safe guarantees about data validity
35+
- Building domain models with complex validation
36+
- Integrating with JSON parsing libraries
37+
1538
### 🧪 kotlin-tdd
1639

1740
Kotlin Test-Driven Development with fakes, object mothers, and Testing Through The Domain.

0 commit comments

Comments
 (0)