Laravel Validation
Validation in Laravel, worked through topic by topic. Each guide leans on running code and explains why a rule exists, not only how to call it.
Topics in this guide
- Quick start How to validate data in Laravel 13: controller validation, Form Requests, Validator::make. Practical examples, error handling, and working with validated data.
- Rules Complete reference of Laravel 13 validation rules with practical examples: required, nullable, sometimes, bail, in, enum, confirmed, prohibited, and more. Side-by-side comparisons of commonly confused rules.
- Strings & numbers Practical recipes for validating strings, numbers, emails, URLs, phone numbers, and regex patterns in Laravel. Covers min/max, size, alpha rules, uuid, and the numeric vs integer distinction.
- Dates How to validate dates, times, timezones, and date ranges in Laravel 13. Covers date, date_format, after, before, timezone, Rule::date() fluent builder, and practical recipes.
- Arrays & JSON Hands-on recipes for validating arrays, nested objects, and JSON in Laravel 13: wildcard rules, distinct, in_array, custom messages, performance, and common pitfalls.
- Files & images How to validate file uploads, image dimensions, MIME types, and file sizes in Laravel 13. Practical recipes with the File rule builder, custom rules for PDFs and CSVs, and common pitfalls.
- Unique & Exists Practical recipes for unique and exists validation in Laravel 13: ignore on update, multi-column uniqueness, soft deletes, conditional exists, pitfalls.
- Passwords How to validate passwords in Laravel 13: Password::min(), mixedCase, numbers, symbols, uncompromised, confirmed, current_password, custom messages, and regex patterns.
- Form Request Move validation logic out of controllers with Form Requests. Covers authorize, rules, prepareForValidation, after hooks, PHP 8 attributes, API usage, and strict mode.
- Error messages Practical recipes for displaying, customizing, and controlling validation error messages in Laravel 13: Blade directives, JSON responses, custom messages, placeholders, MessageBag API, named bags, and localization.
- Custom rules How to build custom validation rules in Laravel 13: Rule classes, closures, implicit rules, DataAwareRule, credit card validation, and debugging tips when validation is not working.
- Conditional Conditional validation rules in Laravel 13: required_if, required_with, required_without, required_unless, exclude_if, sometimes, and checkbox validation with practical examples.