laracraft-tech/laravel-schema-rules
Generate starter Laravel validation rules from your database schema. Create rules for entire tables or selected columns, optionally generate Form Request classes, and configure columns to always skip. Great for fast scaffolding before manual refinement.
Pros:
skip_columns and customizable rule generation, allowing teams to override defaults (e.g., for business-specific constraints).Cons:
numeric for float instead of decimal:8,2). Teams must manually refine for edge cases (e.g., precision, custom formats).exists: rule for foreign keys, which may not cover all use cases (e.g., polymorphic relationships).spatie/laravel-validation-attributes).nullable()) must be reflected in validation rules manually or regenerated.artisan commands), fitting into Laravel’s CLI workflow.float/decimal precision, custom enum values).jsonb vs. MySQL’s json). Teams using mixed drivers may need custom configurations.min: to a string)?StoreUserRequest, UpdatePostRequest).jenssegers/mongodb).users, orders) to validate rule quality.post-migrate hook to regenerate rules after schema changes.# In a custom Artisan command or Git hook
php artisan schema:generate-rules users --create-request
public function rules()
{
$schemaRules = (new SchemaRules)->forTable('users');
return array_merge($schemaRules, [
'email' => ['unique:users,email,' . $this->user->id],
]);
}
jsonb requires v1.3.2+).uuid-ossp), extend the package or skip columns.skip_columns to exclude fields with custom rules (e.g., password, token).| Step | Action | Owner |
|---|---|---|
| 1 | Install package (composer require --dev) |
DevOps/Backend |
| 2 | Publish config (php artisan vendor:publish) |
Backend |
| 3 | Test rule generation on a sample table | QA/Backend |
| 4 | Integrate into CI (optional) | DevOps |
| 5 | Train team on overriding rules | Tech Lead |
| 6 | Roll out to pilot tables | Backend |
php artisan schema:generate-rules users --force
skip_columns in config/schema-rules.php for team-wide exclusions.schema:rules:update command to your custom Artisan commands for team-wide updates.php artisan schema:dump) with generated output.skip_columns is configured correctly..env database config matches the target schema.--columns flag to isolate problematic columns.skip_columns to avoid duplication.# Generate for staging schema
php artisan schema:generate-rules --env=staging users
auth-service:users).How can I help you explore Laravel packages today?