PHPackages                             thedavefulton/laravel-exclusive-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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. thedavefulton/laravel-exclusive-validation-rules

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

thedavefulton/laravel-exclusive-validation-rules
================================================

Two additional validation rules for use with the Laravel framework

1.0.0(6y ago)02MITPHPPHP ^7.1

Since Aug 24Pushed 6y ago1 watchersCompare

[ Source](https://github.com/thedavefulton/laravel-exclusive-validation-rules)[ Packagist](https://packagist.org/packages/thedavefulton/laravel-exclusive-validation-rules)[ Docs](https://github.com/thedavefulton/laravel-exclusive-validation-rules)[ RSS](/packages/thedavefulton-laravel-exclusive-validation-rules/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Rules for ensuring that exactly 1 of n inputs is received
=========================================================

[](#rules-for-ensuring-that-exactly-1-of-n-inputs-is-received)

[![Latest Version on Packagist](https://camo.githubusercontent.com/dcd4edb951e790ae71b78f87c414b7c99c5886663a67f11de4bc22eebf7fd629/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7468656461766566756c746f6e2f6c61726176656c2d6578636c75736976652d76616c69646174696f6e2d72756c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/thedavefulton/laravel-exclusive-validation-rules)[![Build Status](https://camo.githubusercontent.com/8a59ceaf2adcab3606286f02b4bfcb44a6a8ff2a258117d7992e430faf7f1988/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7468656461766566756c746f6e2f6c61726176656c2d6578636c75736976652d76616c69646174696f6e2d72756c65732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/thedavefulton/laravel-exclusive-validation-rules)[![Quality Score](https://camo.githubusercontent.com/528188b1b8d46ef0596248579fae21900ec7c2140b1a02f8f19334c0b23dce9e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7468656461766566756c746f6e2f6c61726176656c2d6578636c75736976652d76616c69646174696f6e2d72756c65732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/thedavefulton/laravel-exclusive-validation-rules)[![Total Downloads](https://camo.githubusercontent.com/15c497996c90ca78c8d72db1f083eb98bf7a62eb1091253f12eb322647fc82bd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7468656461766566756c746f6e2f6c61726176656c2d6578636c75736976652d76616c69646174696f6e2d72756c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/thedavefulton/laravel-exclusive-validation-rules)

This package was born out of a need to ensure that for a set of inputs exactly 1 was received. Using existing validation rules could ensure that at least 1 or no more than 1 would be received, but there wasn't a succinct way of guaranteeing exactly one.

As such, two rules were implemented. The first, `require_exclusive`, ensures that exactly 1 of the inputs will be present. The second, `optional_exclusive`, allows for none of the inputs to be present but if any are present there must be exactly 1.

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

[](#installation)

You can install the package via composer:

```
composer require thedavefulton/laravel-exclusive-validation-rules
```

The package is configured to use Laravel's automatic discovery. However, you can manually register the service provider in the `app/config.php` file:

```
'providers' => [
    // Other Service Providers

    Thedavefulton\ExclusiveValidationRulesServiceProvider::class,
],
```

Usage
-----

[](#usage)

These rules may be used like any standard validation rule.

```
$attributes= $request->validate([
    'input1' => 'required_exclusive:input2',
    'input2' => 'required_exclusive:input1',
]);

$attributes= $request->validate([
    'input1' => 'optional_exclusive:input2',
    'input2' => 'optional_exclusive:input1',
]);
```

They can also be extended to n inputs

```
$attributes= $request->validate([
    'input1' => 'required_exclusive:input2,input3,input4',
    'input2' => 'required_exclusive:input1,input3,input4',
    'input3' => 'required_exclusive:input1,input2,input4',
    'input4' => 'required_exclusive:input1,input2,input3',
]);
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

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

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

[](#contributing)

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

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [David Fulton](https://github.com/thedavefulton)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

2454d ago

### Community

Maintainers

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

---

Tags

laravelrulesvalidationlaravelvalidationrules

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[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)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

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

Allows uniting several validation rules into a single one for easy re-usage

184485.5k](/packages/illuminatech-validation-composite)[galahad/laravel-addressing

Laravel package providing addressing functionality

70316.6k](/packages/galahad-laravel-addressing)[resultsystems/validation

Inspired 'KennedyTedesco Validation' - The power of 'Respect Validation' on Laravel.

2832.4k4](/packages/resultsystems-validation)

PHPackages © 2026

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