aegisora / email-rule
Rule-based email 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
Email Rule provides a simple, rule-based email 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)
- 🔹 Uses native PHP email validation (
filter_var) - 🔹 Fully compatible with Aegisora validation pipeline
- 🔹 Strict
Context → Resultvalidation flow - 🔹 No raw booleans — only structured results
- 🔹 Safe execution via base
Ruleabstraction - 🔹 Ready to use out of the box
📦 Installation
composer require aegisora/email-rule
🚀 Core Concept
This package implements a single validation rule:
- accepts a value via
Context - validates it as an email
- returns a standardized
Result
Validation is performed using PHP’s built-in:
filter_var($value, FILTER_VALIDATE_EMAIL)
🏗️ Basic Usage
Using EmailRule
use Aegisora\Rules\EmailRule; use Aegisora\RuleContract\Models\Context; $rule = EmailRule::create(); $result = $rule->validate(Context::create('user@example.com')); if ($result->isValid()) { // email is valid } else { // email is invalid }
🧠 Implementation Details
EmailRule
- Uses
filter_varfor validation - Returns:
Result::valid()result if email is correctResult::invalid()result if email is incorrect
- Does not throw exceptions for invalid emails
- Fully relies on base
Ruleexecution guarantees
🏛️ Architecture
This package relies on aegisora/rule-contract (https://github.com/Aegisora/rule-contract).
Flow:
validate()is calledexecuteValidate()runs- Result is returned (
Result) - Errors (if any) are safely handled by base
Rule
⚖️ 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.