PHPackages                             drewlabs/laravexists - 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. drewlabs/laravexists

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

drewlabs/laravexists
====================

Library provides existance rule implementation for laravel/lumen based projects

v0.3.2(1y ago)0425MITPHP

Since Dec 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/azandrew-sidoine/php-laravexists)[ Packagist](https://packagist.org/packages/drewlabs/laravexists)[ RSS](/packages/drewlabs-laravexists/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (12)Used By (0)

Laravexists
===========

[](#laravexists)

`Laravexists` package provides developper with utility and classes that calls `exists` rule on data source. It internally use the laravel `Rule::exists()` or an existance verifier class that must provides implementation that check data existance on a given data source.

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

[](#installation)

To install the library in a PHP project, use the composer package manager:

> composer require drewlabs/laravexists

The command above install the library and all it dependencies.

Usage
-----

[](#usage)

- Using the default laravel exists rule

The library can be used as a drop-in replacement for Laravel default `Rule::exists()` validation rule as it support it internally.

```
use Drewlabs\LaravExists\Exists;

//...

class MyRequest extends FormRequest {

    public function rules()
    {
        return [
            // ... validation rules
            'post_id' => [new Exists('posts', 'id')]
            // Or using the factory function
            'post_id' => [Exists::create('posts', 'id')]
        ]
    }
}
```

- Using an HTTP existance verifier

The library comes with an HTTP existance verifier with can be used as a factory instance for verifying existance of a data using REST interface. It's kind of the main purpose of this library as it allow to check if a given data exist on a given server remoetly. The library relies on query parameter do send query that filters the result from the the HTTP server (if supported by the server).

```
// Import the exist validation rule
use Drewlabs\LaravExists\Exists;
// Import the http existance client class
use Drewlabs\LaravExists\HTTPExistanceClient;

//...

class MyRequest extends FormRequest {

    public function rules()
    {
        return [
            // ... validation rules
            'post_id' => [
                Exists::create(
                    HTTPExistanceClient::create(
                        'http://localhost:3000/api/posts',
                    )->withBearerToken($this->bearerToken()),
                    // The attribute used for check on the ressult from the HTTP server
                    'id'
                )
            ]
        ]
    }
}
```

**Note** By default the `HTTPExistanceClient` class uses an internal callback that filter and validate the entry `data` of the server json response. To override the default implementation:

```
// Import the http existance client class
use Drewlabs\LaravExists\HTTPExistanceClient;

// ...
HTTPExistanceClient::create(
    '',
    [], // Http headers
    // The response is a PHP object or array (dictionary)
    // $key is the column or key passed to the Exists construction
    // $value is the value provided by the user
    function($response, $key, $value) {
        // TODO, check if the response contains the data
        return true; // true or false base on the result of the previous step
    }
)
// ...
```

- Custom verifier

The library comes with an interface that can be implemented to provide a custom existance, verifier:

```
use Drewlabs\LaravExists\ExistanceVerifier;

class MyCustomVerifier implements ExistanceVerifier
{
    public function exists(string $column, $value)
    {
        // TODO: Provide existance verification implementation
    }
}
```

- Customize the validation error message (^0.1.2)

Case required to customize the message output to user when validation fails, use the `withMessage()` method or pass a third or fourth argument to the class constructor:

```
use Drewlabs\LaravExists\Exists;

// ...

class MyFormRequest
{

    public function rules()
    {
        return [
            // ...
            'post_id' => [new Exists('table', 'column', 'The selected post_id is invalid')]

            // In case using existance verifier
            'comment_id' => [new Exists(new InstanceClass, 'column', 'The selected post_id is invalid')]
        ]
    }
}
```

**Note** The library is still under development as the API might change.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance43

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~82 days

Recently: every ~105 days

Total

10

Last Release

486d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/48c4973d500c7f4233d5ceacab51a57208d5fb60b0f95ae60264cf92380d0534?d=identicon)[azandrew-sidoine](/maintainers/azandrew-sidoine)

---

Top Contributors

[![azandrew-sidoine](https://avatars.githubusercontent.com/u/23530515?v=4)](https://github.com/azandrew-sidoine "azandrew-sidoine (11 commits)")

---

Tags

laravelvalidationexists

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/drewlabs-laravexists/health.svg)

```
[![Health](https://phpackages.com/badges/drewlabs-laravexists/health.svg)](https://phpackages.com/packages/drewlabs-laravexists)
```

###  Alternatives

[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M106](/packages/propaganistas-laravel-phone)[intervention/validation

Additional validation rules for the Laravel framework

6826.7M8](/packages/intervention-validation)[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)[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

759569.4k13](/packages/wendelladriel-laravel-validated-dto)[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)
