kotlin-sum-types
STARTER_CHARACTER = 🔀
Parse, Don't Validate with Kotlin Sealed Classes
Represent validation states explicitly using sealed classes. This makes invalid states unrepresentable in your domain logic and pushes validation to system boundaries.
Core Principle
Parse, don't validate means transforming untyped input into strongly-typed domain objects at the boundary, carrying proof of validity through the type system.
Instead of:
fun processEmail(email: String) {
if (!isValid(email)) throw ValidationException()
// Every function must revalidate or assume validity
}
More from anderssv/the-example
kotlin-tdd
Kotlin Test-Driven Development with fakes, object mothers, and Testing Through The Domain. Uses TestContext for dependency injection, extension functions for test data, and fakes instead of mocks. Use when writing Kotlin tests or setting up test infrastructure.
23kotlin-context-di
Manual dependency injection using SystemContext (production) and TestContext (test doubles) patterns for Kotlin. Use when structuring service dependencies, wiring application components, or creating test contexts without DI frameworks.
15