PHPackages                             saritasa/laravel-fluent-validation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. saritasa/laravel-fluent-validation

AbandonedArchivedLibrary[Validation &amp; Sanitization](/categories/validation)

saritasa/laravel-fluent-validation
==================================

Set of fluent builders for Laravel request validation rules

1.3.0(2y ago)8232.4k↓32.8%7[1 issues](https://github.com/Saritasa/php-laravel-fluent-validation/issues)[1 PRs](https://github.com/Saritasa/php-laravel-fluent-validation/pulls)1MITPHPPHP &gt;=7.1

Since Jul 5Pushed 2y ago8 watchersCompare

[ Source](https://github.com/Saritasa/php-laravel-fluent-validation)[ Packagist](https://packagist.org/packages/saritasa/laravel-fluent-validation)[ RSS](/packages/saritasa-laravel-fluent-validation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (18)Used By (1)

Fluent Validation Rules builders for Laravel
============================================

[](#fluent-validation-rules-builders-for-laravel)

[![PHP Unit](https://github.com/Saritasa/php-laravel-fluent-validation/workflows/PHP%20Unit/badge.svg)](https://github.com/Saritasa/php-laravel-fluent-validation/actions)[![PHP CodeSniffer](https://github.com/Saritasa/php-laravel-fluent-validation/workflows/PHP%20Codesniffer/badge.svg)](https://github.com/Saritasa/php-laravel-fluent-validation/actions)[![codecov](https://camo.githubusercontent.com/896fcbfdbd6ef69c6cca06a8e9eb1077f3fef1ae901a7db5083996b36ffe1fe3/68747470733a2f2f636f6465636f762e696f2f67682f53617269746173612f7068702d6c61726176656c2d666c75656e742d76616c69646174696f6e2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Saritasa/php-laravel-fluent-validation)[![Release](https://camo.githubusercontent.com/64df36e4854683ab8c83fea3cf1aae8216a962f1160261c8bfe50722ba494f6d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73617269746173612f7068702d6c61726176656c2d666c75656e742d76616c69646174696f6e2e737667)](https://github.com/Saritasa/php-laravel-fluent-validation/releases)[![PHPv](https://camo.githubusercontent.com/66a46bdb679a43921712ca3cb4486219153d536a0c9c1e3938534dad6e4bb95e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f73617269746173612f6c61726176656c2d666c75656e742d76616c69646174696f6e2e737667)](http://www.php.net)[![Downloads](https://camo.githubusercontent.com/57225ef92e555db1f4923c7549ddebde9fe439db2924769674907fca7ca8a0eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73617269746173612f6c61726176656c2d666c75656e742d76616c69646174696f6e2e737667)](https://packagist.org/packages/saritasa/laravel-fluent-validation)

Use fluent-style syntax to build [Laravel validation rules](https://laravel.com/docs/5.4/validation#available-validation-rules)

**Example**:

```
$rules = [
    'id' => Rule::int()->required(),
    'name' => Rule::string()->required()->minLength(3)->toString(),
    'email' => Rule::string()->required()->email()->toArray(),
    'role_id' => Rule::modelExists(Role::class),
    'salary' => Rule::int()->when($isPHPDeveloper,
                             function($ruleWhenTrue) {
                                 return $ruleWhenTrue->min(1000000);
                             },
                             function($ruleWhenFalse) {
                                 return $ruleWhenFalse->max(1000);
                             }
    )
]
```

Advantages
----------

[](#advantages)

- Strong typing
- Intellisence for available rules and parameters (if you use smart IDE, like PHPStorm)
- Hints about mistypings (if you use smart IDE, like PHPStorm)

### Examples

[](#examples)

**Inline documentation:**

[![Inline documentation](docs/inline_docs.png)](docs/inline_docs.png)

**Intellisence:**

[![Intelisence](docs/intellisence.png)](docs/intellisence.png)

**Custom validation rules**

You can also use [custom declared validations](https://laravel.com/docs/5.4/validation#custom-validation-rules):

```
$rules = [
    ... => Rule::custom('foo')
]
```

Installation
------------

[](#installation)

Install the `saritasa/laravel-fluent-validation` package:

```
$ composer require saritasa/laravel-fluent-validation
```

If you use Laravel 5.4 or less, or 5.5+ with [package discovery](https://laravel.com/docs/5.5/packages#package-discovery) disabled, add the FluentValidationServiceProvider in `config/app.php`:

```
'providers' => array(
    // ...
    Saritasa\Laravel\Validation\FluentValidationServiceProvider::class,
)
```

*Note:* You can omit service provider registration, but then you must call *-&gt;toString()* or *-&gt;toArray()* on each builder. If service provider is registered, manual casting of rule to string or array is not necessary and default Laravel's *Illuminate\\Validation\\ValidationServiceProvider::class*can be removed from *'providers'* array.

Available classes
-----------------

[](#available-classes)

### \\Saritasa\\Laravel\\Validation\\Rule

[](#saritasalaravelvalidationrule)

Root of your rule builder.

Contributing
------------

[](#contributing)

1. Create fork, checkout it
2. Develop locally as usual. **Code must follow [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/)** - run [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) to ensure, that code follows style guides
3. **Cover added functionality with unit tests** and run [PHPUnit](https://phpunit.de/) to make sure, that all tests pass
4. Update [README.md](README.md) to describe new or changed functionality
5. Add changes description to [CHANGES.md](CHANGES.md) file. Use [Semantic Versioning](https://semver.org/) convention to determine next version number.
6. When ready, create pull request

### Make shortcuts

[](#make-shortcuts)

If you have [GNU Make](https://www.gnu.org/software/make/) installed, you can use following shortcuts:

- `make cs` (instead of `php vendor/bin/phpcs`) - run static code analysis with [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)to check code style
- `make csfix` (instead of `php vendor/bin/phpcbf`) - fix code style violations with [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)automatically, where possible (ex. PSR-2 code formatting violations)
- `make test` (instead of `php vendor/bin/phpunit`) - run tests with [PHPUnit](https://phpunit.de/)
- `make install` - instead of `composer install`
- `make all` or just `make` without parameters - invokes described above **install**, **cs**, **test** tasks sequentially - project will be assembled, checked with linter and tested with one single command

Resources
---------

[](#resources)

- [Bug Tracker](http://github.com/saritasa/php-laravel-fluent-validation/issues)
- [Code](http://github.com/saritasa/php-laravel-fluent-validation)
- [Changes History](CHANGES.md)
- [Authors](http://github.com/saritasa/php-laravel-fluent-validation/contributors)

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 91.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~148 days

Recently: every ~540 days

Total

17

Last Release

861d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.0

1.2.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/b7632cf2eb5dd552ace9d66947ed6919e19c6a2fdb5dc73b8c71e0f9886ccc83?d=identicon)[saritasa](/maintainers/saritasa)

---

Top Contributors

[![populov](https://avatars.githubusercontent.com/u/3766033?v=4)](https://github.com/populov "populov (77 commits)")[![hollow-en](https://avatars.githubusercontent.com/u/87475798?v=4)](https://github.com/hollow-en "hollow-en (3 commits)")[![maxermolenko](https://avatars.githubusercontent.com/u/11438109?v=4)](https://github.com/maxermolenko "maxermolenko (3 commits)")[![DaviMenezes](https://avatars.githubusercontent.com/u/3998868?v=4)](https://github.com/DaviMenezes "DaviMenezes (1 commits)")

---

Tags

fluentlaravelphprule-buildervalidationlaravelvalidationfluent

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/saritasa-laravel-fluent-validation/health.svg)

```
[![Health](https://phpackages.com/badges/saritasa-laravel-fluent-validation/health.svg)](https://phpackages.com/packages/saritasa-laravel-fluent-validation)
```

###  Alternatives

[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

759569.4k13](/packages/wendelladriel-laravel-validated-dto)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
