Download the PHP package aegisora/instanceof-rule-guardian without Composer
On this page you can find all versions of the php package aegisora/instanceof-rule-guardian. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aegisora/instanceof-rule-guardian
More information about aegisora/instanceof-rule-guardian
Files in aegisora/instanceof-rule-guardian
Package instanceof-rule-guardian
Short Description A simple shortcut for object type validation, built on top of aegisora/guardian and aegisora/instanceof-rule.
License MIT
Homepage https://github.com/Aegisora/instanceof-rule-guardian
Informations about the package instanceof-rule-guardian
Aegisora Instanceof Rule Guardian
Instanceof Rule Guardian provides a simple shortcut for object type validation using aegisora/guardian and aegisora/instanceof-rule.
It is designed for cases where you want to quickly check whether a value is an instance of a given class without manually creating validation pipelines.
This package is built on top of:
โจ Features
- ๐น Simple shortcut API for
InstanceofRule - ๐น Validates whether a value is an instance of a given class
- ๐น Uses
aegisora/guardianinternally - ๐น Uses
aegisora/instanceof-ruleinternally - ๐น Supports custom validation exceptions
- ๐น Fully compatible with the Aegisora ecosystem
- ๐น Ready to use out of the box
๐ฆ Installation
๐ Core Concept
This package wraps the common validation flow:
into a dedicated shortcut class:
Instead of manually creating InstanceofRule and passing it to Guardian, you can use InstanceofRuleGuardian directly.
๐๏ธ Basic Usage
๐งฉ Usage with Custom Exception
You may provide your own exception for validation failure.
If the value is not an instance of User, the provided exception will be thrown.
This is useful when validation errors should have domain-specific meaning.
๐งช Example in Application Service
๐จ Exceptions
This package does not define its own exception types. All errors are raised by the underlying aegisora/guardian package.
Both exceptions extend the abstract base class
Aegisora\Guardian\Exceptions\GuardianException,
so you can catch every validation error with a single catch:
GuardianValidationException
Thrown when validation fails and no custom exception is provided.
GuardianExecutingRuleException
Thrown when the underlying rule execution fails.
Aegisora\Guardian\Exceptions\GuardianExecutingRuleException
๐งฉ API
InstanceofRuleGuardian::check()
Parameters:
$value(mixed) โ value to validate$targetClassName(string) โ fully qualified class name to check against$exception(?\Throwable, defaultnull) โ optional custom exception thrown on validation failure
Returns void. The method communicates results through exceptions only โ it returns nothing on success and throws on failure:
GuardianValidationExceptionโ validation failed and no custom exception was providedGuardianExecutingRuleExceptionโ the underlying rule failed to execute- the provided custom exception โ validation failed and a custom exception was passed
Example:
With custom exception:
๐๏ธ Architecture
This package is a small shortcut layer over the Aegisora validation pipeline.
Flow:
InstanceofRuleGuardian::check()is calledInstanceofRule::create($targetClassName)is createdGuardianexecutes the rule- If validation succeeds, execution continues normally
- If validation fails, custom exception or
GuardianValidationExceptionis thrown - If rule execution fails,
GuardianExecutingRuleExceptionis thrown
Internal flow:
๐ Related Packages
- aegisora/guardian โ validation execution orchestrator
- aegisora/instanceof-rule โ rule-based object type validation
- aegisora/rule-contract โ base rule contract and validation result architecture
โ๏ธ 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.