Weave 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
Rule Builder

Rule Builder Laravel Package

timacdonald/rule-builder

A Laravel package for building custom validation rules with a fluent, object-oriented API. Compose reusable rule objects, keep validation logic clean and testable, and use them directly in form requests or validators.

View on GitHub
Deep Wiki
Context7

Fluent validation rule builder for Laravel.

Frequently asked questions about Rule Builder
What is timacdonald/rule-builder used for in Laravel?
It is a fluent, object-oriented builder for custom Laravel validation rules. You compose reusable rule objects and use them in form requests or validators instead of scattering closure-based validation logic. This keeps validation rules clean, testable, and easy to reuse across endpoints.
How do I install timacdonald/rule-builder?
Install it with Composer using composer require timacdonald/rule-builder. Check the package README and composer constraints first, because major versions can raise the minimum PHP and Laravel versions. The supplied v4 release notes do not indicate a new configuration schema or service-provider migration.
How do I create a custom validation rule with rule-builder?
Define a rule as a class or object using the package's fluent API, then attach it to a validator or form request. The package is designed for composing small, reusable rule objects rather than one-off string rules. Confirm the exact API in the README for your installed major version.
Does rule-builder support Laravel 11 or Laravel 12?
Laravel version support depends on the package major version and its Composer constraints. The v4 release may raise the PHP or Laravel floor, so verify the compatibility matrix before upgrading. Do not assume v4 works on the same Laravel version as v3.
What changed in timacdonald/rule-builder v4.0.0?
The available release note says v4.0.0 removed the optional rule, which is a breaking change. Treat that note as incomplete and read the full changelog for other changes such as renamed classes or raised PHP and Laravel requirements. Audit any validation strings that reference optional before upgrading.
What should I use instead of the optional rule removed in rule-builder v4?
The intended successor is not confirmed by the supplied release note. Possible replacements include Laravel's sometimes or nullable rules, a renamed package rule, or no equivalent, and those choices have different semantics. Map each call site individually rather than doing a blind find-and-replace.
Can I use rule-builder rules in Laravel form requests?
Yes. Rules built with the package are intended for use in form requests and validators. That keeps controller code thin and validation logic in dedicated, testable objects. Check that your form request imports the correct rule class for the installed package version.
How do I test validation rules built with rule-builder?
Because rules are plain objects with a fluent API, you can unit test their behavior and integration test them through Laravel's validator. Add regression tests for each substitution pattern when upgrading, especially where a rule may silently stop failing validation. Use your existing PHPUnit or Pest setup.
Is timacdonald/rule-builder safe to use in production?
The package sits at the HTTP and form-request boundary with no persistence, queue, cache, or event surface, so architectural coupling is low. The main production risk is validation behavior changing silently after a major upgrade. Pin a known-good version and read the changelog before bumping.
How do I migrate from rule-builder v3 to v4 safely?
Audit every occurrence of the removed optional rule in app code, config, tests, seeders, factories, and dynamically assembled rule strings. Define a successor per usage pattern, upgrade on a branch, run the full validation suite, and add regression tests. Canary to staging before production, and pin to ^3.x if the upgrade is not urgent.
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.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
cgv/localized-resource