PHPackages                             ray/validate-module - 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. ray/validate-module

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

ray/validate-module
===================

Validation module for Ray.Di

1.0.1(8y ago)055.4k↓33%31MITPHPPHP &gt;=5.5.0

Since Mar 4Pushed 8y ago2 watchersCompare

[ Source](https://github.com/ray-di/Ray.ValidateModule)[ Packagist](https://packagist.org/packages/ray/validate-module)[ RSS](/packages/ray-validate-module/feed)WikiDiscussions 1.x Synced 2d ago

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

Ray.ValidateModule
==================

[](#rayvalidatemodule)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b31333257f4dda5c8877911e1be0f5f7910d8485e5d116f22f03ef12d48889dd/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7261792d64692f5261792e56616c69646174654d6f64756c652f6261646765732f7175616c6974792d73636f72652e706e673f623d312e78)](https://scrutinizer-ci.com/g/ray-di/Ray.ValidateModule/?branch=1.x)[![Code Coverage](https://camo.githubusercontent.com/771960d670c1a9bb1f0bdc130e20b766aa8fe8e1d7440152add9bb5b0be93592/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7261792d64692f5261792e56616c69646174654d6f64756c652f6261646765732f636f7665726167652e706e673f623d312e78)](https://scrutinizer-ci.com/g/ray-di/Ray.ValidateModule/?branch=1.x)[![Build Status](https://camo.githubusercontent.com/572781fbcd37db812bd1001046db14e946ae9af818c9ad48014b8067262d1881/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7261792d64692f5261792e56616c69646174654d6f64756c652f6261646765732f6275696c642e706e673f623d312e78)](https://scrutinizer-ci.com/g/ray-di/Ray.ValidateModule/build-status/1.x)[![Build Status](https://camo.githubusercontent.com/6a40ec5641a83d0740cb4a5096729d2b269673a7df33914eb50e4b82e2163974/68747470733a2f2f7472617669732d63692e6f72672f7261792d64692f5261792e56616c69646174654d6f64756c652e7376673f6272616e63683d312e78)](https://travis-ci.org/ray-di/Ray.ValidateModule)

Installation
------------

[](#installation)

### Composer install

[](#composer-install)

```
$ composer require ray/validate-module

```

### Module install

[](#module-install)

```
use Ray\Di\AbstractModule;
use Ray\AuraSqlModule\AuraSqlModule;
use Ray\AuraSqlModule\Annotation\AuraSqlConfig;

class AppModule extends AbstractModule
{
    protected function configure()
    {
        $this->install(new ValidateModule);
    }
}
```

### Usage

[](#usage)

Annotate target method with `@Valid` annotation.

```
use Ray\Validation\Annotation\Valid;

class User
{
    /**
     * @Valid
     */
    public function createUser($name)
    {
        // ...
    }
```

Provide `onValidate` annotated method in same class for validation. Method can be named freely.

```
use Ray\Validation\Annotation\OnValidate;
// ...

    /**
     * @OnValidate
     */
    public function onValidate($name)
    {
        $validation = new Validation;
        if (! is_string($name)) {
            $validation->addError('name', 'name should be string');
        }

        return $validation;
    }
```

Validate all parameters in validation method. `addError($name, $message)` with invalid parameter name and message in the case of validation failed.

`Ray\Validation\Exception\InvalidArgumentException` thrown on validation failed, But if `@OnFailure` annoted method exists, The result of `@OnFailure` method returns instead of original.

```
use Ray\Validation\Annotation\OnFailure;
// ...

    /**
     * @OnFailure
     */
    public function onFailure(FailureInterface $failure)
    {

        // original parameters
        list($this->defaultName) = $failure->getInvocation()->getArguments();

        // errors
        foreach ($failure->getMessages() as $name => $messages) {
            foreach ($messages as $message) {
                echo "Input '{$name}': {$message}" . PHP_EOL;
            }
        }
    }
```

If you need multiple validation in one class, You can name validation at annotation property as follows.

```
use Ray\Validation\Annotation\Valid;
use Ray\Validation\Annotation\OnValidate;
use Ray\Validation\Annotation\OnInvalid;
// ...

    /**
     * @Valid("foo")
     */
    public function fooAction($name, $address, $zip)
    {

    /**
     * @OnValidate("foo")
     */
    public function onValidateFoo($name, $address, $zip)
    {

    // ...
    /**
     * @OnInvalid("foo")
     */
    public function onInvalidFoo(FailureInterface $failure)
    {
    // ...
```

### Demo

[](#demo)

```
$ php docs/demo/run.php
// It works!

```

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 95.2% 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

Every ~269 days

Total

5

Last Release

3063d ago

Major Versions

0.1.1 → 1.0.02017-09-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/db4fc75ffc631168d0d7143b6f2c24b1534dfb921212bd851c026c5cbbb1344d?d=identicon)[koriym](/maintainers/koriym)

---

Top Contributors

[![koriym](https://avatars.githubusercontent.com/u/529021?v=4)](https://github.com/koriym "koriym (59 commits)")[![kuma-guy](https://avatars.githubusercontent.com/u/7978290?v=4)](https://github.com/kuma-guy "kuma-guy (2 commits)")[![kenjis](https://avatars.githubusercontent.com/u/87955?v=4)](https://github.com/kenjis "kenjis (1 commits)")

---

Tags

ray-modulevalidationvalidationRay.Di

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ray-validate-module/health.svg)

```
[![Health](https://phpackages.com/badges/ray-validate-module/health.svg)](https://phpackages.com/packages/ray-validate-module)
```

###  Alternatives

[composer/semver

Version comparison library that offers utilities, version constraint parsing and validation.

3.3k522.3M992](/packages/composer-semver)[giggsey/libphonenumber-for-php

A library for parsing, formatting, storing and validating international phone numbers, a PHP Port of Google's libphonenumber.

5.0k159.6M527](/packages/giggsey-libphonenumber-for-php)[respect/validation

The most awesome validation engine ever created for PHP

6.0k39.9M414](/packages/respect-validation)[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k39.7M146](/packages/propaganistas-laravel-phone)[opis/json-schema

Json Schema Validator for PHP

65243.6M302](/packages/opis-json-schema)[giggsey/libphonenumber-for-php-lite

A lite version of giggsey/libphonenumber-for-php, which is a PHP Port of Google's libphonenumber

9216.6M75](/packages/giggsey-libphonenumber-for-php-lite)

PHPackages © 2026

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