PHPackages                             aegisora/emptiness-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. aegisora/emptiness-rule

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

aegisora/emptiness-rule
=======================

Rule-based emptiness validation in Aegisora ecosystem

v1.0.0(1mo ago)00MITPHPPHP &gt;=7.4

Since May 4Pushed 1mo agoCompare

[ Source](https://github.com/Aegisora/emptiness-rule)[ Packagist](https://packagist.org/packages/aegisora/emptiness-rule)[ Docs](https://github.com/Aegisora/emptiness-rule)[ RSS](/packages/aegisora-emptiness-rule/feed)WikiDiscussions main Synced 1w ago

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

Aegisora Emptiness Rule
=======================

[](#aegisora-emptiness-rule)

[![Code Coverage Badge](./badge.svg)](./badge.svg)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![PHPStan Badge](https://camo.githubusercontent.com/83dd3d35cebed0eab9ee97ff1a5849c1344cda6a8ee9cac2cda20f5aa55b67bd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230392d627269676874677265656e2e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/83dd3d35cebed0eab9ee97ff1a5849c1344cda6a8ee9cac2cda20f5aa55b67bd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230392d627269676874677265656e2e7376673f7374796c653d666c6174)

Emptiness Rule provides a simple, rule-based **emptiness validation** implementation for the Aegisora ecosystem.

It is built on top of `aegisora/rule-contract` () and follows its strict validation architecture, ensuring consistent and predictable behavior across applications.

---

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

[](#-features)

- 🔹 Lightweight and minimal dependencies
- 🔹 Validation for **empty** and **non-empty** values
- 🔹 Supports multiple data types (string, array, object, etc.)
- 🔹 Fully compatible with Aegisora validation pipeline
- 🔹 Strict `Context → Result` validation flow
- 🔹 No raw booleans — only structured results
- 🔹 Safe execution via base `Rule` abstraction
- 🔹 Convenient factory methods (`create()`)
- 🔹 Built-in validation of input values

---

📦 Installation
--------------

[](#-installation)

```
composer require aegisora/emptiness-rule
```

---

🚀 Core Concept
--------------

[](#-core-concept)

This package provides validation rules to check whether a value is:

- empty (`EmptyRule`)
- not empty (`NotEmptyRule`)

Validation is performed by:

- receiving a value via `Context`
- checking it against emptiness criteria
- returning a standardized `Result`

---

📐 What is "empty"?
------------------

[](#-what-is-empty)

The following values are considered **empty**:

- `null`
- empty string (`''`)
- empty array (`[]`)
- objects implementing `Countable` with `count() === 0`

The following are **NOT empty**:

- non-empty strings
- non-empty arrays
- numbers (`int`, `float`)
- booleans
- objects (unless `Countable` and empty)

---

🏗️ Basic Usage
--------------

[](#️-basic-usage)

### ✅ Check if value is NOT empty

[](#-check-if-value-is-not-empty)

```
use Aegisora\Rules\Emptiness\NotEmptyRule;
use Aegisora\RuleContract\Models\Context;

$result = NotEmptyRule::create()->validate(Context::create('hello'));

if ($result->isValid()) {
    // value is NOT empty
} else {
    // value is empty
}
```

---

### ❌ Check if value is empty

[](#-check-if-value-is-empty)

```
use Aegisora\Rules\Emptiness\EmptyRule;
use Aegisora\RuleContract\Models\Context;

$result = EmptyRule::create()->validate(Context::create([]));

if ($result->isValid()) {
    // value is empty
} else {
    // value is NOT empty
}
```

---

🧩 Available Rules
-----------------

[](#-available-rules)

```
EmptyRule::create();
NotEmptyRule::create();
```

Both rules:

- accept any value via `Context`
- return a structured `Result`
- follow identical validation logic with inverted outcomes

---

⚠️ Validation Rules
-------------------

[](#️-validation-rules)

Supported input types:

- `null`
- `string`
- `array`
- `int`
- `float`
- `bool`
- `object` (with special handling for `Countable`)

Unsupported types will throw: `Aegisora\RuleContract\Exceptions\InvalidRuleContextException`

---

🏛️ Architecture
---------------

[](#️-architecture)

This package relies on `aegisora/rule-contract` ().

Validation flow:

1. `validate()` is called
2. `Context` is passed in
3. `executeValidate()` runs
4. Value is checked for emptiness
5. Result is determined (valid / invalid)
6. `Result` is returned

All logic is safely encapsulated within the base `Rule` abstraction.

---

⚖️ License
----------

[](#️-license)

This package is open-source and licensed under the MIT License. See the LICENSE for details.

---

🌱 Contributing
--------------

[](#-contributing)

Contributions are welcome and greatly appreciated!. See the CONTRIBUTING for details.

---

🌟 Support
---------

[](#-support)

If you find this project useful, please consider giving it a star on GitHub!

It helps the project grow and motivates further development.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance93

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

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

36d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/81402dcd0a07ad550b7f80f5871e7c302770b29d4c73a52fc35ba697f702d56e?d=identicon)[arslanim](/maintainers/arslanim)

---

Top Contributors

[![arslanim](https://avatars.githubusercontent.com/u/22678154?v=4)](https://github.com/arslanim "arslanim (77 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (15 commits)")

---

Tags

aegisoraaegisora-ecosystememptiness-checkemptiness-ruleempty-rulenot-empty-rulephprule-based-emptiness-predicate-checkphpaegisoraaegisora-ecosystememptinessemptiness-validationemptiness-rule

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/aegisora-emptiness-rule/health.svg)

```
[![Health](https://phpackages.com/badges/aegisora-emptiness-rule/health.svg)](https://phpackages.com/packages/aegisora-emptiness-rule)
```

PHPackages © 2026

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