PHPackages                             elbgoods/laravel-sort-positions-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. elbgoods/laravel-sort-positions-rule

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

elbgoods/laravel-sort-positions-rule
====================================

1.1.0(6y ago)0490MITPHPPHP ^7.4CI failing

Since Mar 4Pushed 6y ago3 watchersCompare

[ Source](https://github.com/elbgoods/laravel-sort-positions-rule)[ Packagist](https://packagist.org/packages/elbgoods/laravel-sort-positions-rule)[ Docs](https://github.com/elbgoods)[ RSS](/packages/elbgoods-laravel-sort-positions-rule/feed)WikiDiscussions master Synced yesterday

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

Sort position rule for Laravel
==============================

[](#sort-position-rule-for-laravel)

This Package provides validation for correct sort position values for arrays.

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

[](#installation)

You can install the package via composer:

```
composer require elbgoods/laravel-sort-positions-rule
```

if you want to adjust the error message translation you can add the translation files to your project:

```
php artisan vendor:publish --provider="Elbgoods\SortPositionsRule\SortPositionsRuleServiceProvider" --tag=lang
```

Usage
-----

[](#usage)

An example array to validate

```
[
    [
        'id' => 1,
        'sort_position' => 1,
        'name' => 'foo'
    ], [
        'id' => 2,
        'sort_position' => 2,
        'name' => 'bar'
    ]
];
```

To validate the sort position values you have to add the `SortPositionsRule` rule to your rule set for the whole array. You must pass in the array key for the sort position in the first parameter (`sort_position` in the example array). Optionally you can pass a start value in the second parameter if you don't want to start your sort position values with 1.

```
use Elbgoods\SortPositionsRule\Rules\SortPositionsRule;

// ...

$rules = [
    // ...
    'array_with_sortable_data' => ['array', new SortPositionsRule('sort_position', 0)],
    // ...
];
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

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

Credits
-------

[](#credits)

- [Niclas Schirrmeister](https://github.com/eisfeuer)
- [Tom Witkowski](https://github.com/Gummibeer)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

Treeware
--------

[](#treeware)

You're free to use this package, but if it makes it to your production environment we would highly appreciate you buying or planting the world a tree.

It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to [plant trees](https://www.bbc.co.uk/news/science-environment-48870920). If you contribute to my forest you’ll be creating employment for local families and restoring wildlife habitats.

You can buy trees at

Read more about Treeware at

[![We offset our carbon footprint via Offset Earth](https://camo.githubusercontent.com/3c7b612cd33ceabed721a1325651b948c1425f67e0b1c11a6e871b5e90635476/68747470733a2f2f746f6f6c6b69742e6f66667365742e65617274682f636172626f6e706f736974697665776f726b666f7263652f62616467652f3565313836653638353136656236303031386335313732623f626c61636b3d74727565266c616e6473636170653d74727565)](https://offset.earth/treeware)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 69.2% 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 ~32 days

Total

2

Last Release

2227d ago

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/33a11c820ca1801a2b0cc065786385f9a1746ae02d1a120102ea7fc7f545eeb7?d=identicon)[Elbgoods](/maintainers/Elbgoods)

---

Top Contributors

[![Gummibeer](https://avatars.githubusercontent.com/u/6187884?v=4)](https://github.com/Gummibeer "Gummibeer (9 commits)")[![eisfeuer](https://avatars.githubusercontent.com/u/12658491?v=4)](https://github.com/eisfeuer "eisfeuer (4 commits)")

---

Tags

elbgoodslaravel-sort-positions-validation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/elbgoods-laravel-sort-positions-rule/health.svg)

```
[![Health](https://phpackages.com/badges/elbgoods-laravel-sort-positions-rule/health.svg)](https://phpackages.com/packages/elbgoods-laravel-sort-positions-rule)
```

###  Alternatives

[spatie/laravel-honeypot

Preventing spam submitted through forms

1.6k6.0M60](/packages/spatie-laravel-honeypot)[proengsoft/laravel-jsvalidation

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

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[sunspikes/clamav-validator

Custom Laravel 5 anti-virus validator for file uploads.

3651.8M3](/packages/sunspikes-clamav-validator)[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)
