Parse, Don't Validate

•
79
•

Enhances code reliability by transforming weak validation checks into robust, type-safe parsing patterns that enforce domain invariants.

This skill implements the 'Parse, Don't Validate' design principle to help developers move away from 'shotgun parsing' and towards type-safe architectures. It identifies anti-patterns where validation results are discarded (returning void or booleans) and refactors them into parsing functions that return specialized types like NonEmptyArray or Smart Constructors. By ensuring that once data is checked, its validity is preserved in the type system, this skill eliminates redundant checks and prevents 'impossible' states across TypeScript, Rust, Go, and other major languages.

主要功能

01Supports multiple languages including TypeScript, Rust, Go, and Python
02Implements Smart Constructors to protect domain primitives
03Detects and fixes 'shotgun parsing' by centralizing boundary checks
0479 GitHub stars
05Identifies validation anti-patterns like void return types and boolean checks
06Refactors legacy validation into type-safe parsing logic

使用场景

01Hardening system boundaries such as API request handling or database input
02Designing robust domain models where invalid states are unrepresentable by the compiler
03Refactoring legacy code to eliminate 'should never happen' comments and null checks