validation

HTML forms with validation and accessibility

HTML5 form validation uses attributes like required, pattern, min, max, and type to validate input. I leverage native validation before JavaScript. The <label> element associates text with inputs for accessibility. Input types like email, tel, u

Soft Validation: Normalize + Validate Email

Normalize before validation to avoid “same email, different casing/whitespace” bugs. Keep normalization deterministic and small; put it in the model so imports, consoles, and controllers all behave the same.

Laravel form requests for validation

Form requests encapsulate validation logic in dedicated classes, keeping controllers thin and focused. Each form request extends FormRequest and defines rules() and optionally authorize() methods. The authorize() method checks if the user can perform

Custom Validator for “At Least One of” Fields

A tiny custom validator keeps complex presence rules out of controllers. This example enforces that at least one of two fields is present (e.g., text content or an attachment).

Database constraints and data validation

Constraints enforce data integrity at the database level. PRIMARY KEY ensures uniqueness and identifies rows. FOREIGN KEY maintains referential integrity. NOT NULL prevents null values. UNIQUE prevents duplicates. CHECK validates data conditions. DEFA

Dry-rb gems for functional programming patterns

Dry-rb provides functional programming tools for Ruby. dry-validation creates complex validation schemas with type checking. dry-types defines strict types—coercion, constraints, sum types. I use dry-struct for immutable data structures with typed att

Validated JSON Schema with dry-validation-style contract (lightweight)

Even without extra gems, you can validate incoming JSON payloads with small “contracts” that coerce and validate keys. It’s a strong reliability upgrade for webhook and API ingestion.

Validation with Bean Validation API

Bean Validation (JSR 380) validates objects using annotations. Common constraints include @NotNull, @NotBlank, @Size, @Email, @Min, @Max, and @Pattern. I apply annotations to fields, methods, or parameters. @Valid triggers validation in Spring control

Django model validation with clean method

The clean() method validates model instances before saving. I raise ValidationError for invalid data. This runs on form submission and can be called explicitly with full_clean(). I validate cross-field constraints that can't be expressed as field vali

Laravel custom validation rules

Custom validation rules encapsulate complex validation logic in reusable classes. I create rule classes implementing ValidationRule with a validate() method receiving the attribute, value, and fail closure. Rules access databases, call APIs, or perfor

Model validations for data integrity

Validations ensure data consistency before persisting to the database, catching invalid states early in the request lifecycle. I combine presence validations for required fields, uniqueness constraints that map to database indexes, and format validati

Runtime validation for request bodies (Zod)

TypeScript only protects you at compile time; your API still receives untrusted JSON from the internet. I lean on Zod as the source of truth for parsing + validation so runtime and types stay aligned. The big win is that I don’t try to validate ‘every