Download the PHP package weloveahmed/laravel-auto-validator without Composer
On this page you can find all versions of the php package weloveahmed/laravel-auto-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download weloveahmed/laravel-auto-validator
More information about weloveahmed/laravel-auto-validator
Files in weloveahmed/laravel-auto-validator
Package laravel-auto-validator
Short Description Automatic validation rules generation for Laravel Eloquent models based on database schema.
License MIT
Informations about the package laravel-auto-validator
Laravel Auto Validator
Automatic validation rules generation for any Eloquent model based on database schema introspection.
โจ Why this package?
Laravel validation is powerful, but writing FormRequests for every model/table can become repetitive.
This package automatically generates validation rules based on your database schema:
- Column types
- Length constraints
- Required vs nullable
- Unique indexes
- Foreign keys (
existsrules)
Then allows you to customize and extend rules using:
- Model overrides
- Reusable profiles
- Multi-tenant constraints
- SoftDeletes-aware uniqueness
- JSON deep validation (nested rules)
โ Features
- Schema Introspection: Generate rules from column types, lengths, nullability, unique indexes, and foreign keys.
- Context-Aware: Supports
storeandupdatecontexts (handles unique ignore automatically). - Overrides: Model-specific overrides via simple PHP files.
- Profiles: Reusable validation templates (e.g.
person,address,api-mobile). - SoftDeletes Aware: Unique rules can ignore soft-deleted rows.
- Multi-Tenant Ready: Add tenant constraints to
uniqueandexists. - JSON Support: Map JSON columns to arrays and validate nested fields.
- Performance: Caching of schema and generated rules.
- Developer Experience: Fluent API + optional Artisan generators.
๐ฆ Installation
Laravel auto-discovers the Service Provider.
โ๏ธ Configuration
Publish the config file:
Config file location: config/auto-validator.php
โก How it works (Internals)
The package follows a simple pipeline:
SchemaReader โ RuleMapper โ RuleFactory โ Overrides โ Profiles โ Context
๐ Basic Usage
This package is designed to work with any Eloquent model.
โ Generate Store Rules
โ Validate Store Data
โ Generate Update Rules
โ Validate Update Data
๐งฉ Model Overrides
Create a file: app/AutoValidation/Employee.php
๐ง Profiles (Reusable Rule Sets)
Define profiles in config:
Apply profile:
๐ข Multi-Tenancy Support
Implement TenantResolver:
Bind it in your AppServiceProvider:
๐ SoftDeletes-Aware Unique Rules
Only needed if your model uses SoftDeletes.
๐งพ JSON Deep Validation
To validate nested JSON data, add overrides:
๐ฆ Bulk Import (Enterprise Feature)
๐ Artisan Commands
โ Testing
โ Compatibility
PHP: 8.2+ Laravel: 10+
๐ Security
If you discover any security issues, please email: [email protected]
๐ค Contributing
Contributions are welcome! Submit PRs with tests.
๐ License
MIT License. See LICENSE.md
All versions of laravel-auto-validator with dependencies
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/validation Version ^10.0|^11.0|^12.0