Fluent Rule Builders for All Laravel Validation Rules | Mohamed Said       [Skip to content](#main)  [ ![](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png) Mohamed SaidLaravel Backend Engineer ](https://www.msaied.com) - [Home](https://www.msaied.com)
- [Projects](https://www.msaied.com/projects)
- [Articles](https://www.msaied.com/articles)
- [Certificates](https://www.msaied.com/certificates)
- [About](https://www.msaied.com#about)

           [  Contact](https://www.msaied.com#contact) Menu 

Menu
----

Close 

 - [HomeStart here](https://www.msaied.com)
- [ProjectsCase studies](https://www.msaied.com/projects)
- [ArticlesEngineering notes](https://www.msaied.com/articles)
- [CertificatesCredentials](https://www.msaied.com/certificates)
- [AboutHow I work](https://www.msaied.com#about)
- [ContactGet in touch](https://www.msaied.com#contact)

  [Start a conversation](https://www.msaied.com#contact) [WhatsApp](https://wa.me/201094619204) [Email](mailto:hello@msaied.com) 

 1. [Home](https://www.msaied.com)
2. /
3. [Articles](https://www.msaied.com/articles)
4. /
5. [Laravel](https://www.msaied.com/articles?category=laravel)
6. /
7. Fluent Rule Builders for All Laravel Validation Rules

   [Laravel](https://www.msaied.com/articles?category=laravel) [Tips &amp; Tricks](https://www.msaied.com/articles?category=tips-tricks) 

 Fluent Rule Builders for All Laravel Validation Rules
======================================================

 Laravel 13.36 adds fluent Rule class builders for every validation rule that was previously string-only, giving you autocomplete, type safety, and correct handling of values that contain commas.

 ![](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp) [Mohamed Said](https://www.msaied.com#person) Published 16 Oct 2026 · Updated 16 Oct 2026 · 4 min read

ShareCopy linkCopied

 ![Fluent Rule Builders for All Laravel Validation Rules](https://cdn.msaied.com/787/3dbb2870a99a7e4609f817339f391a5e.png) 

  On this page +1. [Why String Validation Rules Fall Short](#why-string-validation-rules-fall-short)
2. [Before and After](#before-and-after)
3. [Three Categories of New Builders](#three-categories-of-new-builders)
4. [Rules Without Parameters](#rules-without-parameters)
5. [Rules That Take Fields or Values](#rules-that-take-fields-or-values)
6. [Rules With Chainable Options](#rules-with-chainable-options)
7. [Solving the Comma Problem](#solving-the-comma-problem)
8. [Key Takeaways](#key-takeaways)

 Why String Validation Rules Fall Short
--------------------------------------

Laravel's string-based validation rules are concise, but they come with real drawbacks. Your editor cannot autocomplete `required_without:email`, a typo in the rule name only surfaces at runtime, and values that contain commas break the colon-and-comma parsing format entirely.

The `Rule` class already provided fluent builders for a handful of rules — `in`, `unique`, `exists`, `enum`, `date`, `email`, and `file`. **Laravel 13.36** extends that coverage to every rule that was still string-only.

Before and After
----------------

Here is a profile form using the old string style:

```php
$request->validate([
    'email'     => 'required_without:phone|email',
    'phone'     => 'required_without:email',
    'website'   => 'nullable|url:https',
    'device_id' => 'uuid:4',
    'tags.*'    => 'distinct:ignore_case',
    'password'  => 'required|confirmed',
    'timezone'  => 'timezone:per_country,US',
]);

```

The same rules rewritten with the new builders:

```php
use Illuminate\Validation\Rule;

$request->validate([
    'email'     => [Rule::requiredWithout('phone'), 'email'],
    'phone'     => [Rule::requiredWithout('email')],
    'website'   => [Rule::nullable(), Rule::url()->protocols(['https'])],
    'device_id' => [Rule::uuid()->version(4)],
    'tags.*'    => [Rule::distinct()->ignoreCase()],
    'password'  => [Rule::required(), Rule::confirmed()],
    'timezone'  => [Rule::timezone(['per_country', 'US'])],
]);

```

String rules still work, and you can freely mix both styles in the same array.

Three Categories of New Builders
--------------------------------

### Rules Without Parameters

These return a plain string. `Rule::required()` is simply the string `required`. The full set includes `accepted()`, `activeUrl()`, `bail()`, `base64()`, `boolean()`, `declined()`, `exclude()`, `filled()`, `hexColor()`, `json()`, `list()`, `macAddress()`, `missing()`, `nullable()`, `present()`, `prohibited()`, `required()`, `sometimes()`, and `ulid()`.

One small extra: passing `true` to `Rule::boolean()` produces `boolean:strict`, which accepts only the literal values `true` and `false`.

### Rules That Take Fields or Values

These accept field names or values as individual arguments or as an array:

```php
Rule::requiredWith('first_name', 'last_name');
Rule::acceptedIf('plan', 'pro');
Rule::requiredArrayKeys('street', 'city', 'postcode');

```

The full list covers `acceptedIf`, `declinedIf`, `excludeWith`, `excludeWithout`, `inArray`, `missingIf`, `prohibits`, `requiredWith`, `requiredWithout`, `timezone`, and many more conditional variants.

### Rules With Chainable Options

These return an object with methods for the rule's options:

```php
Rule::url()->protocols(['https']);             // url:https
Rule::uuid()->version(7);                      // uuid:7
Rule::ip()->version(6);                        // ipv6
Rule::distinct()->strict()->ignoreCase();      // distinct:strict,ignore_case
Rule::confirmed()->customField('repeat_pass'); // confirmed:repeat_pass
Rule::currentPassword()->guard('admin');       // current_password:admin

```

`Rule::ip()->version()` accepts only `4` or `6` and throws an `InvalidArgumentException` for anything else. `Rule::uuid()->version()` additionally accepts the strings `'nil'` and `'max'`.

The existing date builder also gains an `equals()` method in this release:

```php
Rule::date()->equals('2026-12-31');
Rule::date()->equals(today());

```

Solving the Comma Problem
-------------------------

The string format splits parameters on commas, so a value like `Team, Annual` is silently parsed as two separate values. The new builders that accept fields or values implement a `ParameterizedRule` contract whose `toArray()` method passes parameters directly to the validator as an array — no string parsing involved:

```php
// String format breaks: reads as two values "Team" and " Annual"
'terms' => 'accepted_if:plan,Team, Annual',

// Builder works correctly
'terms' => [Rule::acceptedIf('plan', 'Team, Annual')],

```

This also handles values containing pipes, backslashes, and double quotes. Non-string values (`true`, `false`, `null`) are automatically converted to their string equivalents.

Key Takeaways
-------------

- Laravel 13.36 adds fluent `Rule` builders for every previously string-only validation rule.
- Three builder types: parameter-less (return a string), field/value-based (accept arguments), and option-based (return a chainable object).
- The `ParameterizedRule` contract fixes long-standing issues with commas and special characters in rule values.
- String rules remain fully supported; you can mix styles in the same array.
- `Rule::ip()->version()` and `Rule::uuid()->version()` enforce valid version numbers at build time.
- Contributor: Eric ([@ericmp33](https://github.com/ericmp33)) via PR [\#61833](https://github.com/laravel/framework/pull/61833).

---

*Source: [Fluent Rule Builders for All Laravel Validation Rules — Laravel News](https://laravel-news.com/laravel-validation-rule-builders)*

- [Laravel](https://www.msaied.com/articles?search=Laravel)
- [Validation](https://www.msaied.com/articles?search=Validation)
- [Laravel 13](https://www.msaied.com/articles?search=Laravel%2013)
- [PHP](https://www.msaied.com/articles?search=PHP)
- [Rule Builder](https://www.msaied.com/articles?search=Rule%20Builder)

 Frequently asked questions 
---------------------------

  Do I have to rewrite my existing string validation rules to use the new builders?No. String rules continue to work exactly as before. The new builders are opt-in, and you can mix string rules and builder objects in the same validation array.

   Why do the new builders handle commas in values better than string rules?String rules split parameters on commas, so a value like 'Team, Annual' is parsed as two separate values. Builders that accept fields or values implement the ParameterizedRule contract, which passes parameters to the validator as a PHP array rather than a parsed string, preserving commas and other special characters.

   What happens if I pass an invalid version number to Rule::ip()-&gt;version()?Rule::ip()-&gt;version() accepts only 4 or 6. Passing any other number throws an InvalidArgumentException immediately when the rule is built, rather than failing silently at validation time.

   ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)About the author
----------------

[Mohamed Said](https://www.msaied.com#person)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

[About](https://www.msaied.com#about) [GitHub ↗](https://github.com/EG-Mohamed) [LinkedIn ↗](https://www.linkedin.com/in/msaiedm/) [WhatsApp ↗](https://wa.me/201094619204) [Email Address ↗](mailto:hello@msaied.com) [My CV ↗](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)  

   [Previous articleLaravel URL AI Transformer: Extract Structured Data From URLs](https://www.msaied.com/articles/laravel-url-ai-transformer-extract-structured-data-from-urls)  

   On this page
-------------

1. [Why String Validation Rules Fall Short](#why-string-validation-rules-fall-short)
2. [Before and After](#before-and-after)
3. [Three Categories of New Builders](#three-categories-of-new-builders)
4. [Rules Without Parameters](#rules-without-parameters)
5. [Rules That Take Fields or Values](#rules-that-take-fields-or-values)
6. [Rules With Chainable Options](#rules-with-chainable-options)
7. [Solving the Comma Problem](#solving-the-comma-problem)
8. [Key Takeaways](#key-takeaways)

 ###  Have a technical challenge?

 Tell me what you’re building. I reply within two working days.

[Start a conversation](https://www.msaied.com#contact) 

   Related articles
-----------------

 [ ![](https://cdn.msaied.com/782/215fd94331f880a70b7bfaf16528790d.png) Composer Pacakge · 4 min read### Laravel URL AI Transformer: Extract Structured Data From URLs

14 Oct 2026 ](https://www.msaied.com/articles/laravel-url-ai-transformer-extract-structured-data-from-urls) [ ![](https://cdn.msaied.com/784/000a77bb8acd1c5452f67943b3bbc48b.png) Laravel · 4 min read### Add Email to Any Laravel Cloud Environment with the Resend Integration

14 Oct 2026 ](https://www.msaied.com/articles/add-email-to-any-laravel-cloud-environment-with-the-resend-integration) [ ![](https://cdn.msaied.com/781/c4463b384b964fd45e6f3cfa00f8e95c.png) Laravel · 4 min read### Rule Builders for Every Validation Rule in Laravel 13.36

14 Oct 2026 ](https://www.msaied.com/articles/rule-builders-for-every-validation-rule-in-laravel-1336) 

  Have a technical challenge?
----------------------------

Tell me what you’re building. I reply within two working days.

 [Discuss your project ↗](https://www.msaied.com#contact) 

  © 2026 Mohamed Said · Built with Laravel, meant to last.Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

 - [Home](https://www.msaied.com)
- [Articles](https://www.msaied.com/articles)
- [Certificates](https://www.msaied.com/certificates)
- [GitHub](https://github.com/EG-Mohamed)
- [LinkedIn](https://www.linkedin.com/in/msaiedm/)
- [WhatsApp](https://wa.me/201094619204)
- [Email Address](mailto:hello@msaied.com)
- [My CV](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
- [Sitemap](https://www.msaied.com/sitemap.xml)
