Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Schema Rules

Laravel Schema Rules Laravel Package

laracraft-tech/laravel-schema-rules

Generate basic Laravel validation rules from your database schema. Create rules for entire tables or selected columns, scaffold Form Request classes, and configure columns to always skip. Great as a starting point to refine and optimize validation.

View on GitHub
Deep Wiki
Context7

Automatically generate Laravel validation rules based on your database table schema!

Frequently asked questions about Laravel Schema Rules
How do I install Laravel Schema Rules in my Laravel project?
Run `composer require laracraft-tech/laravel-schema-rules --dev` to install the package, then publish the config with `php artisan vendor:publish --tag="schema-rules-config"`. This sets up the default configuration for skipped columns and other settings.
Can I generate validation rules for specific columns instead of an entire table?
Yes, use the `--columns` flag with the `schema:generate-rules` command to target specific columns. For example, `php artisan schema:generate-rules users --columns=email,name` will generate rules only for those two columns.
Does Laravel Schema Rules support PostgreSQL’s jsonb or UUID data types?
The package supports basic PostgreSQL types but may not fully handle jsonb or UUID out of the box. You’ll need to manually override rules for these columns or extend the package to support them via custom drivers or config adjustments.
How do I generate a FormRequest class directly from the schema?
Use the `--create-request` flag with the `schema:generate-rules` command. For example, `php artisan schema:generate-rules users --create-request` will generate a `StoreUserRequest` class in the `app/Http/Requests` directory with auto-generated validation rules.
Will this package work with Laravel 10 or older versions?
The package officially supports Laravel 11–13. For Laravel 10, use version 1.3.6 of the package, which includes backward compatibility. Always check the [release notes](https://github.com/laracraft-tech/laravel-schema-rules/releases) for version-specific details.
What happens if my database schema changes after generating rules?
Rules become stale if the schema changes. To stay updated, regenerate rules manually or integrate the `schema:generate-rules` command into your CI/CD pipeline (e.g., GitHub Actions) to run on schema migrations or pull requests.
Can I skip certain columns from rule generation globally?
Yes, publish the config file and add column names to the `skip_columns` array in the `schema-rules.php` config. For example, `skip_columns => ['created_at', 'updated_at']` will exclude these columns from rule generation for all tables.
Does this package handle floating-point precision (e.g., decimal(10,2)) correctly?
Currently, the package generates generic numeric rules for floats/decimals without precision/scale validation. You’ll need to manually override these rules in your FormRequest or validation logic to enforce specific precision requirements.
How do I test validation rules generated by this package?
Treat auto-generated rules as a starting point. Write unit tests for your FormRequest classes (e.g., using Laravel’s `TestCase`) to validate both the generated rules and any custom overrides. Ensure edge cases like null values, max lengths, and custom constraints are covered.
Are there alternatives to Laravel Schema Rules for schema-driven validation?
Alternatives include manually writing validation rules or using packages like `spatie/laravel-model-states` for state-based validation. However, Laravel Schema Rules is unique in its focus on auto-generating rules directly from your database schema, reducing boilerplate and keeping validation aligned with your data model.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony