Intervention Validation is a powerful extension library for Laravel's validation system, designed by Oliver Vogel to simplify the validation of specialized data formats. Built to integrate seamlessly with Laravel's existing validation infrastructure, this package expands your validation capabilities without requiring you to change your workflow or learn complex new systems.
Key Features
Intervention Validation enhances Laravel's validation capabilities with a comprehensive set of specialized validation rules:
- Simple Integration: Works with Laravel's existing Validator
- Customizable Error Messages: Full support for custom error messages through Laravel's language files
- Financial Data Validation: Verify IBANs, BICs, credit card numbers, and other financial identifiers
- Document Verification: Validate ISBNs, EANs and others
- Color Values: Check hexadecimal color codes, HSV and HSL formats
- Geographic Validation: Check postal codes, latitude and longitude
- Data Format Verification: Confirm data matches specific patterns like usernames, ULID, JWT, Base64 encoding or Data URIs
- and more
Examples
use Illuminate\Support\Facades\Validator;use Intervention\Validation\Rules\Isbn;use Intervention\Validation\Rules\Creditcard;use Intervention\Validation\Rules\Hexadecimalcolor;use Intervention\Validation\Rules\Username; $validator = Validator::make($request->all(), [ 'book_id' => new Isbn(), // pass as an object 'cc_number' => ['required', 'creditcard'], // or pass rule as string 'hex_color' => 'required|hexadecimalcolor', 'username' => 'required|username',]);
For custom validation error messages, add the corresponding key to /resources/lang/<language>/validation.php
like this:
'iban' => 'Please enter a valid IBAN number.','creditcard' => 'Enter a valid credit card number.',
Give it a try by installing the package using Composer:
composer require intervention/validation
Read the official documentation to learn more about this package and view the source code on GitHub.