Skip to content

Latest commit

 

History

54 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aegisora Instanceof Rule

Code Coverage Badge Software License PHPStan Badge

Instanceof Rule provides a simple, rule-based object type validation 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)
  • 🔹 Native PHP instanceof validation
  • 🔹 Fully compatible with Aegisora validation pipeline
  • 🔹 Strict Context → Result validation flow
  • 🔹 No raw booleans — only structured results
  • 🔹 Safe execution via base Rule abstraction
  • 🔹 Simple factory API (create)
  • 🔹 Ready to use out of the box

📦 Installation

composer require aegisora/instanceof-rule

🚀 Core Concept

This package implements a single validation rule:

  • accepts a value via Context
  • checks whether it is an instance of a given class
  • returns a standardized Result

Internally uses PHP native operator:

$value instanceof ClassName

🏗️ Basic Usage

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

class User {}

$result = InstanceofRule::create(User::class)->validate(Context::create(new User()));

if ($result->isValid()) {
    // value is instance of User
} else {
    // value is not instance of User
}

🧩 Factory Methods

InstanceofRule::create($className);
  • $className — fully qualified class name (FQCN)

🏛️ Architecture

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

Flow:

  1. validate() is called
  2. Context is passed in
  3. executeValidate() runs
  4. instanceof check is executed
  5. Result is returned

All logic is safely handled by Rule contract.


⚖️ 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

Instanceof Rule provides a simple, rule-based object type validation implementation for the Aegisora ecosystem.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages