PHPackages                             cnaebadi/null-replacer - 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. cnaebadi/null-replacer

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

cnaebadi/null-replacer
======================

A Laravel validation rule to remove or replace null fields before validation.

v1.0.0(1y ago)501MITPHPPHP &gt;=8.0

Since May 6Pushed 12mo ago1 watchersCompare

[ Source](https://github.com/cnaebadi/null-replacer)[ Packagist](https://packagist.org/packages/cnaebadi/null-replacer)[ RSS](/packages/cnaebadi-null-replacer/feed)WikiDiscussions main Synced 1mo ago

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

 [![Null Replacer Logo](https://raw.githubusercontent.com/cnaebadi/null-replacer/main/.github/assets/banner.png)](https://raw.githubusercontent.com/cnaebadi/null-replacer/main/.github/assets/banner.png)

Null Replacer
=============

[](#null-replacer)

A Laravel validation rule to automatically remove, replace, or convert null values in request data before validation.

[![Latest Version on Packagist](https://camo.githubusercontent.com/25dddf59cff0577bfa0a244ef8bd67a5506788c451a2825a3389ae535a194285/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636e6165626164692f6e756c6c2d7265706c616365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cnaebadi/null-replacer)[![Total Downloads](https://camo.githubusercontent.com/f1331e719397f983c38a2953b2084390e955d2ea37c23f389c387455300cae50/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636e6165626164692f6e756c6c2d7265706c616365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cnaebadi/null-replacer)[![License: MIT](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)

---

✨ Features
----------

[](#-features)

- Replace `null` values with a **custom value**
- Convert `'true'` and `'false'` strings to actual **boolean** values
- **Remove** null fields entirely from the request
- Can be used **directly in Form Request rules**

---

🚀 Installation
--------------

[](#-installation)

```
composer require cnaebadi/null-replacer
```

---

🧪 Usage
-------

[](#-usage)

⚠️ Note: When using `null_replacer`, you do **not** need to use `nullable`. This rule handles null values entirely on its own and using nullable before it may interfere with its functionality.

In your Laravel Form Request:

---

```
public function rules()
{
    return [
        'optional_note'  => ['null_replacer'], // Removes key if null
        'is_active'      => ['null_replacer:true'], // Converts to boolean true
        'email'          => ['null_replacer:default@example.com'], // Replaces null with given default
    ];
}
```

---

🛠 How It Works
--------------

[](#-how-it-works)

- `null-replacer:true`: `'true'`/`'false'` → `true`/`false`
- `null-replacer:something`: replaces `null` with `"something"`
- `null-replacer (no value)`: removes the key from the request if it's `null`

---

📦 Publish &amp; Extend
----------------------

[](#-publish--extend)

If you want to customize the behavior, you can publish the config (if added later) or extend the core rule logic in your own classes.

---

🧑‍💻 Author
----------

[](#‍-author)

#### Sina Ebadi

[](#sina-ebadi)

---

📄 License
---------

[](#-license)

The MIT License (MIT). Please see License File for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance49

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

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

373d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/961ccb069b001f13e4347489d06972da2aacc01316b2ca94bb422ec7a24c8b5f?d=identicon)[cnaebadi](/maintainers/cnaebadi)

---

Top Contributors

[![cnaebadi](https://avatars.githubusercontent.com/u/45448941?v=4)](https://github.com/cnaebadi "cnaebadi (10 commits)")[![shaedrich](https://avatars.githubusercontent.com/u/11225821?v=4)](https://github.com/shaedrich "shaedrich (3 commits)")

---

Tags

laravelnullnull-safetyphpvalidation

### Embed Badge

![Health badge](/badges/cnaebadi-null-replacer/health.svg)

```
[![Health](https://phpackages.com/badges/cnaebadi-null-replacer/health.svg)](https://phpackages.com/packages/cnaebadi-null-replacer)
```

###  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)
