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.
- 🔹 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
composer require aegisora/boolean-ruleThis 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.
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
}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
}BooleanRule::createTruthy();
BooleanRule::createFalsy();createTruthy()— expectstruecreateFalsy()— expectsfalse
The input value must strictly be a boolean:
truefalse
Any other type (int, string, null, etc.) will throw an exception:
Aegisora\RuleContract\Exceptions\InvalidRuleContextException
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.
This package is open-source and licensed under the MIT License. See the LICENSE for details.
Contributions are welcome and greatly appreciated!. See the CONTRIBUTING for details.
If you find this project useful, please consider giving it a star on GitHub!
It helps the project grow and motivates further development.