What problem does it solve?
This Skill prevents bugs, security vulnerabilities, and data corruption by ensuring all external inputs are rigorously checked for validity. It shifts from "garbage in, garbage out" to "garbage in, nothing out" or "garbage in, error message out," making software robust and reliable.
Core Features & Use Cases
- Two-Level Defense: Distinguishes between
assertions (for programmer errors) and error handling (for expected production anomalies).
- Comprehensive Checks: Guides you to validate types, ranges, formats, lengths, and security risks for all untrusted data sources (user input, APIs, files, DB).
- Robustness vs. Correctness: Helps you consciously decide the appropriate error response strategy (e.g., raise exception, return neutral value, log and continue).
- Use Case: Before processing user registration data, use this skill to validate email format, password strength, age range, and ensure all required fields are present, raising specific
ValueError or TypeError exceptions for invalid inputs.
Quick Start
I need to write a function process_user_data(data: dict). Guide me through identifying all potential invalid inputs for a user dictionary (e.g., missing fields, invalid email, age out of range) and implementing robust validation using both assertions and error handling.