PHPackages                             eastree/uniquewith-validator - 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. eastree/uniquewith-validator

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

eastree/uniquewith-validator
============================

Custom Laravel Validator for combined unique indexes

3.1.3(8y ago)1341MITPHPPHP &gt;=5.4.0

Since Jan 2Pushed 8y agoCompare

[ Source](https://github.com/easttree/uniquewith-validator)[ Packagist](https://packagist.org/packages/eastree/uniquewith-validator)[ Docs](https://github.com/felixkiss/uniquewith-validator)[ RSS](/packages/eastree-uniquewith-validator/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (4)Versions (23)Used By (0)

unique\_with Validator Rule For Laravel
=======================================

[](#unique_with-validator-rule-for-laravel)

[![Build Status](https://camo.githubusercontent.com/8cb7168ddbc04d225e769ff2bd9ea1d0c091afb72ca11335fb927d36be12a803/68747470733a2f2f7472617669732d63692e6f72672f66656c69786b6973732f756e69717565776974682d76616c696461746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/felixkiss/uniquewith-validator)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/032e1d58533d8bb76eb7d3b7b05e7fa9da267df862dcf117e36dd6054e6b8fcd/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f66656c69786b6973732f756e69717565776974682d76616c696461746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/felixkiss/uniquewith-validator/?branch=master)

This package contains a variant of the `validateUnique` rule for Laravel, that allows for validation of multi-column UNIQUE indexes.

Documentation for older versions
--------------------------------

[](#documentation-for-older-versions)

- [Laravel 4](https://github.com/felixkiss/uniquewith-validator/blob/2.0.8/README.md#laravel-4)

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

[](#installation)

Install the package through [Composer](http://getcomposer.org). On the command line:

```
composer require felixkiss/uniquewith-validator

```

Configuration
-------------

[](#configuration)

Add the following to your `providers` array in `config/app.php`:

```
'providers' => [
    // ...

    Felixkiss\UniqueWithValidator\ServiceProvider::class,
],
```

Usage
-----

[](#usage)

Use it like any `Validator` rule:

```
$rules = [
    '' => 'unique_with:,[,,...,]',
];
```

See the [Validation documentation](http://laravel.com/docs/validation) of Laravel.

### Specify different column names in the database

[](#specify-different-column-names-in-the-database)

If your input field names are different from the corresponding database columns, you can specify the column names explicitly.

e.g. your input contains a field 'last\_name', but the column in your database is called 'sur\_name':

```
$rules = [
    'first_name' => 'unique_with:users, middle_name, last_name = sur_name',
];
```

Example
-------

[](#example)

Pretend you have a `users` table in your database plus `User` model like this:

```
