Skip to content

Latest commit

 

History

99 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aegisora Scalar Equality Rule

Code Coverage Badge Software License PHPStan Badge

Scalar Equality Rule provides a simple, rule-based scalar value comparison implementation for the Aegisora ecosystem.

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


✨ Features

  • 🔹 Lightweight and dependency-free (except rule contract)
  • 🔹 Strict scalar comparison using ===
  • 🔹 Supports both equality and inequality checks
  • 🔹 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 (createEqual, createNotEqual)
  • 🔹 Built-in validation of input values

📦 Installation

composer require aegisora/scalar-equality-rule

🚀 Core Concept

This package implements scalar comparison validation:

  • accepts a value via Context
  • compares it to an expected scalar value
  • uses strict comparison (===)
  • returns a standardized Result

Supported values:

  • scalar types (int, float, string, bool)
  • null

Any non-scalar value will result in an exception.


🏗️ Basic Usage

✅ Equality check

use Aegisora\Rules\ScalarEqualityRule;
use Aegisora\RuleContract\Models\Context;

$result = ScalarEqualityRule::createEqual(42)->validate(Context::create(42));

if ($result->isValid()) {
    // values are equal
} else {
    // values are NOT equal
}

❌ Inequality check

use Aegisora\Rules\ScalarEqualityRule;
use Aegisora\RuleContract\Models\Context;

$result = ScalarEqualityRule::createNotEqual(42)->validate(Context::create(100));

if ($result->isValid()) {
    // values are NOT equal (as expected)
} else {
    // values are equal (unexpected)
}

🧩 Factory Methods

ScalarEqualityRule::createEqual($expectedValue);
ScalarEqualityRule::createNotEqual($expectedValue);
  • $expectedValue — scalar value or null

⚠️ Validation Rules

Both expected value and input value must be:

  • scalar (int, float, string, bool)
  • or null

Otherwise, an exception will be thrown:

Aegisora\RuleContract\Exceptions\InvalidRuleContextException

🏛️ Architecture

This package relies on aegisora/rule-contract (https://github.com/Aegisora/rule-contract).

Validation flow:

  1. validate() is called
  2. Context is passed in
  3. executeValidate() runs
  4. Values are validated as scalar or null
  5. Strict comparison (===) is performed
  6. Result is returned

All logic is safely 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.

About

Scalar Equality Rule provides a simple, rule-based scalar value comparison implementation for the Aegisora ecosystem.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages