#validation

40 snippets tagged with #validation

typescriptbeginner

Environment Variable Validator

Validates required environment variables at startup and returns a typed config object or throws with missing keys.

Best for: App startup validation

#config#validation
typescriptbeginner

Express Zod Request Validation

Validate Express request body, params, and query with Zod schemas via reusable middleware.

Best for: API input validation

#express#zod
typescriptintermediate

Request Validation Schema Builder

Build a lightweight request validation layer with type inference for API endpoints.

Best for: API request body validation

#nodejs#validation
typescriptintermediate

Schema Validation with Zod-like Patterns

Build a minimal schema validation library inspired by Zod using TypeScript type inference.

Best for: API request validation

#nodejs#validation
typescriptbeginner

Type-Safe Configuration Loader

Load and validate configuration from environment variables with type coercion and required field checks.

Best for: Application configuration management

#nodejs#config
typescriptbeginner

Environment Secrets Loader

Loads and validates required environment variables at startup and throws meaningful errors for missing ones.

Best for: Application bootstrap

#env#config
typescriptadvanced

OpenAPI Request Validator

Validates incoming request body against a JSON schema derived from an OpenAPI spec.

Best for: API input validation

#openapi#validation
typescriptintermediate

useFormValidation Hook

Lightweight form validation hook with field-level errors, touched tracking, and submit handling.

Best for: Contact forms

#hooks#forms
typescriptintermediate

React Form Validation Hook

A type-safe form validation hook with field-level errors, dirty tracking, and submit handling.

Best for: Type-safe form handling without libraries

#react#forms
typescriptintermediate

Controlled Form Component

A reusable controlled form pattern with field-level validation and submission handling.

Best for: Login forms

#form#controlled
typescriptintermediate

Type-Safe API Route Handler

Next.js App Router route handler with input validation, typed responses, and proper error handling.

Best for: CRUD API endpoints

#api#route-handler
typescriptintermediate

Server Action with Form Validation

Next.js Server Action handling form submissions with validation, error messages, and redirect on success.

Best for: Blog post creation

#server-actions#forms
typescriptbeginner

Environment Variable Validation

Validate required environment variables at build time with type-safe access and descriptive errors.

Best for: App startup checks

#environment#validation
typescriptintermediate

Next.js Server Actions with Forms

Use Server Actions for form handling with validation, optimistic updates, and error handling.

Best for: Form submissions without API routes

#nextjs#server-actions
typescriptadvanced

Form with Server Action Validation

Build forms using Next.js server actions with server-side validation, error handling, and useActionState.

Best for: Contact form submissions

#nextjs#forms
typescriptintermediate

Server Action Validation with Zod

Validate form data in server actions using Zod schemas with type-safe error handling.

Best for: contact forms

#nextjs#zod
typescriptintermediate

File Upload with Server Action

Handle file uploads using server actions with validation, size limits, and storage.

Best for: image uploads

#nextjs#file-upload
typescriptintermediate

Environment Variable Validation with Zod

Validate environment variables at build time using Zod to catch misconfigurations early.

Best for: build-time validation

#nextjs#env
pythonbeginner

Dataclass with Validation

Python dataclass with __post_init__ field validation, type coercion, and descriptive error messages.

Best for: Data transfer objects

#dataclass#validation
pythonbeginner

Pydantic v2 Model Patterns

Define and validate data models with Pydantic v2 using field validators, computed fields, and serialization.

Best for: API request/response models

#pydantic#validation
pythonbeginner

Dataclasses with Post-Init Processing

Use Python dataclasses with __post_init__ for computed fields, validation, and default factories.

Best for: Domain models

#dataclasses#python
pythonintermediate

Dataclass with __post_init__ Validation

Add custom validation to Python dataclasses using __post_init__.

Best for: Input validation

#python#dataclass
pythonintermediate

Data Validation with Pydantic Models

Define and validate data models with Pydantic for type-safe Python applications.

Best for: API request validation

#python#pydantic
typescriptintermediate

LLM JSON Output Parser

Parse and validate JSON responses from LLMs with retry logic and schema enforcement using Zod.

Best for: Extracting structured data from LLM responses

#llm#json-parsing
pythonadvanced

Output Guardrails for LLM Responses

Validate and sanitize LLM outputs to prevent hallucination and injection.

Best for: Safety filtering

#ai#guardrails
pythonadvanced

Text-to-SQL with Validation Safety

Convert natural language to SQL with LLM and validate queries before execution for safety.

Best for: safe NL2SQL

#nl2sql#sql
pythonintermediate

Data Validation with Pydantic

Validate and parse data records using Pydantic models with custom validators and error reporting.

Best for: Validating incoming data before warehouse loading

#validation#pydantic
pythonintermediate

Data Quality Testing with Expectations

Define and run data quality expectations for automated validation in data pipelines.

Best for: Automated data quality gates in pipelines

#data-quality#testing
pythonadvanced

Great Expectations Data Quality Suite

Define and run a Great Expectations validation suite to catch data quality issues early.

Best for: CI data validation

#great-expectations#data-quality
pythonintermediate

Pandera DataFrame Schema Validation

Use Pandera to validate DataFrame schemas with type checks, value constraints, and custom checks.

Best for: pipeline input validation

#pandera#validation
pythonintermediate

Pydantic Models for ETL Validation

Parse and validate raw JSON records against Pydantic models before inserting into a database.

Best for: input validation

#pydantic#validation
pythonintermediate

Pandas Merge with Validation

Use merge() validate parameter to catch unexpected many-to-many or missing key issues in joins.

Best for: data integrity

#pandas#merge
pythonintermediate

Pandera @check_input and @check_output

Decorate pipeline functions with Pandera schema validators to enforce input and output contracts.

Best for: contract testing

#pandera#validation
javaintermediate

Spring Boot — Custom Validator Annotation

Create custom validation annotations with ConstraintValidator for domain-specific field validation.

Best for: Domain-specific input validation

#spring-boot#validation
javaintermediate

Java Regex — Pattern Matching Examples

Common regex patterns with Pattern and Matcher: email, URL, phone, extraction, and replacement.

Best for: Input validation for emails, URLs, and phone numbers

#java#regex
kotlinbeginner

Preconditions — require, check, and error

Validate inputs and state with Kotlin preconditions: require, check, error, and custom assertions.

Best for: Input validation at function boundaries

#kotlin#validation
kotlinbeginner

Kotlin Regex Pattern Matching

Use Kotlin regex for validation, extraction, replacing, and destructuring with named groups.

Best for: Input validation for forms and APIs

#kotlin#regex
kotlinintermediate

Kotlin Error Handling Patterns

Comprehensive error handling: sealed result types, validated aggregation, and railway-oriented programming.

Best for: Form validation with error accumulation

#kotlin#error-handling
scalaintermediate

Error Accumulation with Validated

Accumulate multiple validation errors instead of failing fast using Cats Validated and custom validators.

Best for: Form validation with all errors

#scala#validation
scalaintermediate

Refined and Constrained Types

Create constrained types with validation: non-empty strings, bounded numbers, and validated domain types.

Best for: Domain type validation

#scala#refined