aegisora / boolean-rule
Rule-based boolean value equality validation in Aegisora ecosystem
Requires
- php: >=7.4
- aegisora/rule-contract: ^1.0
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^9.6
- squizlabs/php_codesniffer: ^4.0
README
Boolean Rule provides a simple and strict boolean value equality validation for the Aegisora ecosystem.
The package is built on top of aegisora/rule-contract and follows its validation architecture, ensuring predictable and safe behavior.
✨ Features
- 🔹 Minimalistic implementation with no extra dependencies
- 🔹 Strict type validation (
boolonly) - 🔹 Comparison using
=== - 🔹 Supports validation for both
trueandfalse - 🔹 Fully compatible with Aegisora validation pipeline
- 🔹 Clear
Context → Resultflow - 🔹 No raw booleans — only structured
Result - 🔹 Safe execution via base
Ruleabstraction - 🔹 Convenient factory methods (
createTruthy,createFalsy) - 🔹 Built-in input validation
📦 Installation
composer require aegisora/boolean-rule
🚀 Core Concept
This package performs boolean validation:
- accepts a value via
Context - ensures the value is of type
bool - compares it with the expected value
- returns a standardized
Result
Supported values:
truefalse
Any other value will result in an exception.
🏗️ Basic Usage
✅ Validate true
use Aegisora\Rules\BooleanRule; use Aegisora\RuleContract\Models\Context; $result = BooleanRule::createTruthy()->validate(Context::create(true)); if ($result->isValid()) { // value is true (as expected) } else { // value is not true }
❌ Validate false
use Aegisora\Rules\BooleanRule; use Aegisora\RuleContract\Models\Context; $result = BooleanRule::createFalsy()->validate(Context::create(false)); if ($result->isValid()) { // value is false (as expected) } else { // value is not false }
🧩 Factory Methods
BooleanRule::createTruthy(); BooleanRule::createFalsy();
createTruthy()— expectstruecreateFalsy()— expectsfalse
⚠️ Validation Rules
The input value must strictly be a boolean:
truefalse
Any other type (int, string, null, etc.) will throw an exception:
Aegisora\RuleContract\Exceptions\InvalidRuleContextException
🏛️ Architecture
This package relies on aegisora/rule-contract.
Validation flow:
validate()is calledContextis passedexecuteValidate()is executed- Value type is validated (
boolonly) - Strict comparison (
===) is performed - A
Resultis returned
All logic is encapsulated within the base Rule abstraction.
⚖️ License
This package is open-source and licensed under the MIT License. See the LICENSE for details.
🌱 Contributing
Contributions are welcome and greatly appreciated!. See the CONTRIBUTING for details.
🌟 Support
If you find this project useful, please consider giving it a star on GitHub!
It helps the project grow and motivates further development.