Validating Inputs

Validates external inputs with type, range, format, and null checks.

Updated Nov 27, 2025
One-click install
npx skills add https://github.com/barrydobson/dotfiles_extra --skill validating-inputs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Validating Inputs
Source: https://github.com/barrydobson/dotfiles_extra/tree/main/packages/claude/dot-claude/skills/coding/validating-inputs
Command: npx skills add https://github.com/barrydobson/dotfiles_extra --skill validating-inputs

SYSTEM DOCUMENTATION & REQUIREMENTS

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.

Frequently Asked Questions about Validating Inputs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I validate user input to prevent bugs and security issues?

Input validation checks external data—user submissions, API responses, files, database results—against type, range, format, and null constraints before processing. This prevents garbage data from causing bugs, corrupting state, or creating security vulnerabilities by rejecting or raising errors on invalid inputs.

What's the difference between assertions and error handling in input validation?

Assertions catch programmer errors during development and should fail fast; error handling manages expected production anomalies gracefully. Use assertions for invariants that should never occur if code is correct, and error handling for untrusted external inputs that may legitimately be invalid.

How do I implement robust validation for user registration data?

Validate each field against its constraints: check email format, password strength, age range, required field presence. Raise specific exceptions (ValueError, TypeError) when validation fails, providing explicit error messages. This ensures only clean data enters downstream processing.

What data sources need input validation?

Validate all external inputs: user-submitted forms, API responses, database query results, file contents, and network data. Any data crossing a system boundary from an untrusted source requires validation to ensure data integrity and prevent processing corrupted or malicious input.

Can I use input validation for both small scripts and large production systems?

Yes. Input validation applies to any scale and context where external data enters your system. The two-level defense strategy—assertions for development, robust error handling for production—scales from simple functions to complex distributed systems.

What happens if I skip input validation?

Skipping validation risks data corruption, unexpected exceptions deep in processing logic, security vulnerabilities, and hard-to-debug failures. Invalid data propagates through your system, making root-cause analysis difficult and leaving your application vulnerable to garbage input.