Commit 6f5af71
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
15 | 38 | | |
16 | 39 | | |
17 | 40 | | |
| |||
0 commit comments