PHPackages                             moe-mizrak/validator-guard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. moe-mizrak/validator-guard

ActivePackage[Validation &amp; Sanitization](/categories/validation)

moe-mizrak/validator-guard
==========================

ValidatorGuard enables attribute-driven validation to control Laravel method behavior.

v1.0.1(1y ago)92MITPHPPHP ^8.2CI failing

Since Dec 22Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/moe-mizrak/validator-guard)[ Packagist](https://packagist.org/packages/moe-mizrak/validator-guard)[ Docs](https://github.com/moe-mizrak/validator-guard)[ RSS](/packages/moe-mizrak-validator-guard/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Validator Guard
===============

[](#validator-guard)

[![Latest Version on Packagist](https://camo.githubusercontent.com/01770246ba7288185f44b3583d8d6db62b7836bf76cf6ac0dc87c0bd7afa83c1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7061636b61676973742d76312e302d626c7565)](https://packagist.org/packages/moe-mizrak/validator-guard)

[ ![reboosty](https://camo.githubusercontent.com/f6477f05b28ec7e577e5be83b9aa44855657628be63797b3c145b0716d127035/68747470733a2f2f7265626f6f7374792d7265626f6f7374792e76657263656c2e6170702f6170693f7265706f5f75726c3d68747470733a2f2f6769746875622e636f6d2f6d6f652d6d697a72616b2f76616c696461746f722d6775617264)](https://reboosty-reboosty.vercel.app/api?repo_url=https://github.com/moe-mizrak/validator-guard)ValidatorGuard enables attribute-driven validation to control Laravel method behavior.

---

*Attribute validation is a powerful way to validate method parameters, method results, and method behavior in a declarative way.*

```
// class UserService
#[IntervalGuard(lowerBound: 100, operator: 'getTransactionAmount($transactionId);
/*
 * If the transaction amount is not between 100 and 10,000, the exception will be thrown/logged (based on throwing or logging enabled in config).
 * If the transaction amount is between 100 and 10,000, the method will be executed and give the result.
 */
```

### Attributes

[](#attributes)

More attributes will be added in the future. You can also create/add your custom attributes as explained in the [Create Your Own Attribute](#create-your-own-attribute) section. We will cover the following attributes in this section:

- [IntervalGuard](#intervalguard)
- [DateGuard](#dateguard)
- [AllowedValuesGuard](#allowedvaluesguard)
- [CallbackGuard](#callbackguard)
- [ArrayKeysExistGuard](#arraykeysexistguard)

Tip

Attribute flags as follows:

- **TARGET\_METHOD** : Marks that attribute declaration is allowed only in class methods.
- **IS\_REPEATABLE** : Attribute declaration in the same place is allowed multiple times.
- **TARGET\_PARAMETER** : Marks that attribute declaration is allowed only in function or method parameters.

#### IntervalGuard

[](#intervalguard)

The `IntervalGuard` attribute is used to validate the method result within a specified interval. Attribute flags for the `IntervalGuard`: **TARGET\_METHOD**, **IS\_REPEATABLE**

`IntervalGuard` is listed in the **after** array in the configuration file **attributes** option because it validates the method result after the method execution.

Sample usage:

```
// class UserService
#[IntervalGuard(lowerBound: 100, operator: '=')]
public function getTransactionAmount(int $transactionId): float
{
    // Logic of transaction amount calculation
}
```

In this example, the `getTransactionAmount` method result will be validated by the `IntervalGuard` attribute twice after the method execution. The first validation will check if the transaction amount is bigger than 10, and the second validation will check if the transaction amount is less than or equal to 30.

- Potential use-cases for `IntervalGuard` Attribute:
    - Age Validation:

    ```
    #[IntervalGuard(lowerBound: 18, operator: ' If you find this package useful, please consider ⭐ it to show your support!

📜 License
---------

[](#-license)

Validator Guard is an open-sourced software licensed under the **[MIT license](LICENSE)**.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance46

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

504d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/178c884a892aaf6813e8af8e2cb685bc987a168d9a0ebe9336455a795247ff96?d=identicon)[moe-mizrak](/maintainers/moe-mizrak)

---

Top Contributors

[![moe-mizrak](https://avatars.githubusercontent.com/u/12977885?v=4)](https://github.com/moe-mizrak "moe-mizrak (58 commits)")

---

Tags

allowed-values-guardannotationsarray-keys-exist-guardattribute-validationattributescallback-guarddate-guardinterval-guardlaravellaravel-validator-guardmoe-mizrakphp8valguardvalidationvalidatorvalidatorguardlaravelvalidationdependencystatepermissionattributesMoe MizrakValidatorGuardAttribute Validationlaravel-validator-guard

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/moe-mizrak-validator-guard/health.svg)

```
[![Health](https://phpackages.com/badges/moe-mizrak-validator-guard/health.svg)](https://phpackages.com/packages/moe-mizrak-validator-guard)
```

###  Alternatives

[laravel-lang/attributes

Translation of form element names

273.8M11](/packages/laravel-lang-attributes)[stuyam/laravel-phone-validator

A phone validator for Laravel using the free Twilio phone lookup service.

2861.3k](/packages/stuyam-laravel-phone-validator)[skysplit/laravel5-intl-translation

Laravel 5 package for better translation syntax using php-intl extension

10106.2k](/packages/skysplit-laravel5-intl-translation)[pacerit/laravel-polish-validation-rules

Simple Polish Validation rules for Laravel and Lumen framework

1449.9k](/packages/pacerit-laravel-polish-validation-rules)[laravel-validation-rules/ip

Validate if an ip address is public or private.

1729.7k](/packages/laravel-validation-rules-ip)[cohensive/validation

Extra functionality for Laravel 5 Validator.

1513.9k](/packages/cohensive-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
