PHPackages                             topview-digital/laravel-unique-json-rule - 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. topview-digital/laravel-unique-json-rule

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

topview-digital/laravel-unique-json-rule
========================================

1.0(7y ago)25.2k2MITPHPPHP &gt;=7.0.0CI failing

Since Mar 14Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/robinhoo1973/laravel-unique-json-rule)[ Packagist](https://packagist.org/packages/topview-digital/laravel-unique-json-rule)[ RSS](/packages/topview-digital-laravel-unique-json-rule/feed)WikiDiscussions master Synced today

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

![GitHub release](https://camo.githubusercontent.com/b017aa333cde81f4e1e7f7519e0b49e7f08d0e4e716d19fc02ea9a669edf9643/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f726f62696e686f6f313937332f6c61726176656c2d756e697175652d6a736f6e2d72756c652e737667)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0f9cfe3b2464f218ad3bfb5799d3f2a26a58c475493b260d44af5020a4f41a2d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726f62696e686f6f313937332f6c61726176656c2d756e697175652d6a736f6e2d72756c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/robinhoo1973/laravel-unique-json-rule/?branch=master)[![Build Status](https://camo.githubusercontent.com/66ff4eb7a2b98f58aeef5c608fcd7fe30d2bccfc0e742ccbf56e34342b6b7472/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726f62696e686f6f313937332f6c61726176656c2d756e697175652d6a736f6e2d72756c652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/robinhoo1973/laravel-unique-json-rule/build-status/master)[![Code Intelligence Status](https://camo.githubusercontent.com/19d5dd4da9c514481e0d6cc1df5cd6bc09d44e382bc7b45fe7ea81578749c4e5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726f62696e686f6f313937332f6c61726176656c2d756e697175652d6a736f6e2d72756c652f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)![License](https://camo.githubusercontent.com/db3bb62e4cbf8cd1380b568b29f78b2cbe8db1af9ad97131be5da7d8e26d8651/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f70766965772d6469676974616c2f6c61726176656c2d756e697175652d6a736f6e2d72756c652e737667)[![Total Downloads](https://camo.githubusercontent.com/e6e8513457ab29f9fea70150163fb0641229ee54ad3405e20e40a382ca2c8dbe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f70766965772d6469676974616c2f6c61726176656c2d756e697175652d6a736f6e2d72756c652e737667)](https://packagist.org/packages/topview-digital/laravel-unique-json-rule)[![HitCount](https://camo.githubusercontent.com/675d607383730d266916f1494154fa6ddc1ff10e2404a33f5cb469291edefc0a/687474703a2f2f686974732e6477796c2e696f2f726f62696e686f6f313937332f68747470733a2f2f6769746875622e636f6d2f726f62696e686f6f313937332f6c61726176656c2d756e697175652d6a736f6e2d72756c652e737667)](http://hits.dwyl.io/robinhoo1973/https://github.com/robinhoo1973/laravel-unique-json-rule)

Laravel Unique Json
===================

[](#laravel-unique-json)

#### Check if a record value in a JSON column is unique in the database.

[](#check-if-a-record-value-in-a-json-column-is-unique-in-the-database)

Implementations of Json field unqiue validation rule and inspired by [codezero-be/laravel-unique-translation](https://github.com/codezero-be/laravel-unique-translation)

Requirements
------------

[](#requirements)

- PHP &gt;= 7.0
- MySQL &gt;= 5.7
- [Laravel](https://laravel.com/) &gt;= 5.6

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

[](#installation)

Require the package via Composer:

```
composer require topview-digital/laravel-unique-json-rule

```

Laravel will automatically register the [ServiceProvider](https://github.com/robinhoo1973/laravel-unique-json-rule/blob/master/src/UniqueJsonRuleServiceProvider.php).

Usage
-----

[](#usage)

For the following examples

### Validate an Array of Contacts

[](#validate-an-array-of-contacts)

Your form can also submit an array of contact.

```

```

We need to validate the entire array in this case.

```
$attributes = request()->validate([
    'contact.name' => 'unique_json:clients,contact->name',
    'contact.email' => UniqueJsonRule::for('clients','contact->email'),
]);
```

### Ignore a Record with ID

[](#ignore-a-record-with-id)

If you're updating a record, you may want to ignore the post itself from the unique check.

```
$attributes = request()->validate([
    'contact.name' => 'unique_json:clients,contact->name,{$client->id}',
    'contact.email' => UniqueJsonRule::for('clients','contact->email')->ignore($client->id),
]);
```

### Ignore Records with a Specific Column and Value

[](#ignore-records-with-a-specific-column-and-value)

If your ID column has a different name, or you just want to use another column:

```
$attributes = request()->validate([
    'contact.name' => 'unique_json:clients,contact->name,{$client->uuid},uuid',
    'contact.email' => UniqueJsonRule::for('clients','contact->email')->ignore($client->uuid,'uuid'),
]);
```

Error Messages
--------------

[](#error-messages)

You can pass your own error message with any of the following keys. The first one found will be used.

```
$attributes = request()->validate([
    'contact.name' => 'unique_json:clients,contact->name,{$client->id}',
], [
    'contact.name.unique_json' => 'Your custom :attribute error.',
]);
```

Changelog
---------

[](#changelog)

See a list of important changes in the [changelog](https://github.com/robinhoo1973/laravel-unique-json-rule/blob/master/CHANGELOG.md).

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/robinhoo1973/laravel-unique-json-rule/blob/master/LICENSE.md) for more information.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance53

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.5% 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

Unknown

Total

1

Last Release

2616d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0694c9e94177dbc71edcdceacc627d1cb772220e6b098f0929db8fc89814381c?d=identicon)[robinhoo1973](/maintainers/robinhoo1973)

---

Top Contributors

[![robinhoo1973](https://avatars.githubusercontent.com/u/6511003?v=4)](https://github.com/robinhoo1973 "robinhoo1973 (21 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/topview-digital-laravel-unique-json-rule/health.svg)

```
[![Health](https://phpackages.com/badges/topview-digital-laravel-unique-json-rule/health.svg)](https://phpackages.com/packages/topview-digital-laravel-unique-json-rule)
```

###  Alternatives

[carsdotcom/laravel-json-schema

Json Schema validation for Laravel projects

1036.7k3](/packages/carsdotcom-laravel-json-schema)

PHPackages © 2026

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