kotlin-sum-types
Installation
SKILL.md
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
}