PHPackages                             soyhuce/laravel-validation-rules - 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. [Database &amp; ORM](/categories/database)
4. /
5. soyhuce/laravel-validation-rules

ActiveLibrary[Database &amp; ORM](/categories/database)

soyhuce/laravel-validation-rules
================================

A set of useful validation rules for Laravel

2.1.0(1y ago)012.9k[5 PRs](https://github.com/Soyhuce/laravel-validation-rules/pulls)MITPHPPHP ^8.3CI passing

Since Mar 9Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/Soyhuce/laravel-validation-rules)[ Packagist](https://packagist.org/packages/soyhuce/laravel-validation-rules)[ Docs](https://github.com/soyhuce/laravel-validation-rules)[ GitHub Sponsors](https://github.com/soyhuce)[ RSS](/packages/soyhuce-laravel-validation-rules/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (16)Used By (0)

A set of useful validation rules for Laravel
============================================

[](#a-set-of-useful-validation-rules-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/13e4d61d8723da14b9f1e65cc795b3a7c3a94b04e840b6100000895faa8cd235/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f79687563652f6c61726176656c2d76616c69646174696f6e2d72756c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/soyhuce/laravel-validation-rules)[![GitHub Tests Action Status](https://camo.githubusercontent.com/10a71f45bb33b2a138c006b9f9ab8cd32c63261c3db8a5776604942bda544f76/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736f79687563652f6c61726176656c2d76616c69646174696f6e2d72756c65732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/soyhuce/laravel-validation-rules/actions/workflows/run-tests.yml)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/3002fc2eb4eff15a612814692f5ffd3a137460229447c36c26b76b016fbba6e1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736f79687563652f6c61726176656c2d76616c69646174696f6e2d72756c65732f7068707374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d7068707374616e267374796c653d666c61742d737175617265)](https://github.com/soyhuce/laravel-validation-rules/actions/workflows/phpstan.yml)[![GitHub PHPStan Action Status](https://camo.githubusercontent.com/672aa5274c1711b260516e529ded903b1948ad78ab246da54c1b6cf192639b2f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736f79687563652f6c61726176656c2d76616c69646174696f6e2d72756c65732f7068702d63732d66697865722e796d6c3f6272616e63683d6d61696e266c6162656c3d7068702d63732d6669786572267374796c653d666c61742d737175617265)](https://github.com/soyhuce/laravel-validation-rules/actions/workflows/php-cs-fixer.yml)[![Total Downloads](https://camo.githubusercontent.com/56451fdb1c5efa615eab650662bc6566b379d5ba210de90a13d2f9f6606acab7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f79687563652f6c61726176656c2d76616c69646174696f6e2d72756c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/soyhuce/laravel-validation-rules)

Main objective of this package is to provide a set of validation rules for Laravel in order to make it easier to write validation.

```
Validator::make($data, rules([
	'email' => ['required', DbRules::string()], // ['required', 'string', 'max:255']
	'smaller' => ['nullable', DbRules::string(20)], // ['nullable', 'string', 'max:20']
	'birthday' => [DbRules::date()], // ['date_format:Y-m-d']
	'tiny' => [DbRules::tinyInteger()], // ['integer', 'min:-128', 'max:127']
	// ...
]));
```

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

[](#installation)

You can install the package via composer:

```
composer require soyhuce/laravel-validation-rules
```

Usage
-----

[](#usage)

### Available Rules

[](#available-rules)

Database related rules :

- `DbRules::string`
- `DbRules::boolean`
- `DbRules::enum`
- `DbRules::date`
- `DbRules::dateTime`
- `DbRules::tinyInteger`
- `DbRules::unsignedTinyInteger`
- `DbRules::smallInteger`
- `DbRules::unsignedSmallInteger`
- `DbRules::mediumInteger`
- `DbRules::unsignedMediumInteger`
- `DbRules::integer`
- `DbRules::unsignedInteger`
- `DbRules::bigInteger`
- `DbRules::unsignedBigInteger`
- `DbRules::smallIncrements`
- `DbRules::mediumIncrements`
- `DbRules::increments`
- `DbRules::bigIncrements`
- `DbRules::float`
- `DbRules::double`

Miscellaneous rules :

- `MisRules::safePassword` : GDPR/CNIL compatible password (at least 12 characters)
- `MisRules::mediumPassword` : GDPR/CNIL compatible password (at least 8 characters)

### Using in conditional `Rule::when`

[](#using-in-conditional-rulewhen)

Rules extending `CompoundRule` cannot be used directly in `Rule::when`.

You will need to use `...` in this case :

```
'commission_account' => Rule::when(
    fn(Fluent $data) => $data->get('commission') !== null,
-   ['required', DbRules::string()],
+   ['required', ...DbRules::string()],
    'exclude'
),
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Bastien Philippe](https://github.com/bastien-phi)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance75

Regular maintenance activity

Popularity24

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~120 days

Recently: every ~88 days

Total

10

Last Release

439d ago

Major Versions

1.6.0 → 2.0.02024-12-30

PHP version history (3 changes)1.0.0PHP ^8.1

1.3.0PHP ^8.2

2.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/206cfbf866a463f7e7d1e86946d59b82f4191b9c89f9981fb03eeb264d77af79?d=identicon)[SoyHuCe](/maintainers/SoyHuCe)

---

Top Contributors

[![bastien-phi](https://avatars.githubusercontent.com/u/10199039?v=4)](https://github.com/bastien-phi "bastien-phi (28 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (18 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (12 commits)")[![EdenMl](https://avatars.githubusercontent.com/u/70885551?v=4)](https://github.com/EdenMl "EdenMl (8 commits)")[![ElRochito](https://avatars.githubusercontent.com/u/1737307?v=4)](https://github.com/ElRochito "ElRochito (3 commits)")

---

Tags

hacktoberfestlaravelvalidationlaravelvalidationdatabasesoyhuce

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/soyhuce-laravel-validation-rules/health.svg)

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

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[watson/validating

Eloquent model validating trait.

9723.3M46](/packages/watson-validating)[proengsoft/laravel-jsvalidation

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

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8703.0M17](/packages/yajra-laravel-oci8)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)

PHPackages © 2026

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