PHPackages                             alaa/magento2-input-validation - 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. alaa/magento2-input-validation

AbandonedArchivedMagento2-module[Validation &amp; Sanitization](/categories/validation)

alaa/magento2-input-validation
==============================

Magento2 Rv Input Validation Based on Respect Validation

1.0.0(8y ago)221MITPHP

Since Jan 6Pushed 8y ago1 watchersCompare

[ Source](https://github.com/alaa-almaliki/magento2-input-validation)[ Packagist](https://packagist.org/packages/alaa/magento2-input-validation)[ RSS](/packages/alaa-magento2-input-validation/feed)WikiDiscussions master Synced 1mo ago

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

Magento Input Validation
========================

[](#magento-input-validation)

Based on [Respect Validation](http://respect.github.io/Validation)

Check full list of [Rules](http://respect.github.io/Validation/docs/validators.html)

Installation
============

[](#installation)

1. Install by composer `composer require alaa/magento2-input-validation`
2. Enable the module `php bin/magento module:enable Alaa_RvInputValidation`
3. Magento upgrade `php bin/magento setup:upgrade`

Usage
=====

[](#usage)

1. Backend
----------

[](#1-backend)

This is very simple to use in the backend, you can use the method of your choice that suits the requirement

1. validteInput: this will validate input with a single rule. it accepts two arguments input value as a string and a rule as an array.
2. validate: this will validate input with multiple rules. it loops through rules and call `validateInput` method.
3. validatePostData and validateGetData: this will validate multiple inputs and multiple rules for each input

The array rule elements are:

1. class: required class name such as Email, NotEmpty, Between and etc. This is used to instantiate the validation rule object
2. args: an optional element used to pass into the validation class constructor

Example

```

    // Initialize validation class
    public function __construct(ValidationInterface $validation)
    {
        $this->validation = $validation;
    }

    // valid
    $isEmail = $this->validation->validateInput('alaa.almaliki@gmail.com', ['class' => 'Email']);
    $isUrl = $this->validation->validateInput('https://google.com', ['class' => 'Url']);
    $isLegalAge = $this->validation->validateInput('22', ['class' => 'Between', 'args' => ['min' => '18', 'max' => '22']]);
    var_dump($isEmail, $isUrl, $isLegalAge);

    // invalid
    $isEmail = $this->validation->validateInput('alaa.almaliki@gmail', ['class' => 'Email']);
    $isUrl = $this->validation->validateInput('google.com', ['class' => 'Url']);
    $isLegalAge = $this->validation->validateInput('22', ['class' => 'Between', 'args' => ['min' => '18', 'max' => '20']]);
    var_dump($isEmail, $isUrl, $isLegalAge);

    // validate method work on multiple rules for each input
    $isEmail = $this->validation->validate('alaa.almaliki@gmail.com', [['class' => 'NotEmpty'], ['class' => 'Email']]);
    var_dump($isEmail);

    $validationResults = $this->validation->validatePostData(
                ['email' => 'alaa.almaliki@gmail.com', 'url' => 'https://google.com'],
                [
                    'email' => [
                        [
                            'class' => 'Email',
                            'success_message' => 'Valid Email',
                            'failure_message' => 'Not Valid Email',
                        ],
                    ],
                    'url' => [
                        [
                            'class' => 'Url',
                            'success_message' => 'Valid Url',
                            'failure_message' => 'Not Valid Url',
                        ]
                    ]
                ]
            );

            // results = [
            //      'email' => ['is_valid' => true|false, 'message' => 'Valid Email'|'Not Valid Email'],
            //      'url' => ['is_valid' => true|false, 'message' => 'Valid Url'|'Not Valid Url']
            // ]
            var_dump($validationResults);

    // this is an alias of validate post method
    // just to show that you can use multiple rules here for one input
    $emailGetResults = $this->validation->validateGetData(
        ['email' => 'alaa.almaliki@gmail.com'],
        [
            'email' => [
                [
                    'class' => 'NotEmpty',
                    'success_message' => 'Valid Email',
                    'failure_message' => 'Not Valid Email',
                ],
                [
                    'class' => 'Email',
                    'success_message' => 'Valid Email',
                    'failure_message' => 'Not Valid Email',
                ],
            ],
        ]
    );

    // results = ['is_valid' => true|false, 'message' => 'Valid Email'|'Not Valid Email']
    var_dump($emailGetResults);

```

2. Frontend
-----------

[](#2-frontend)

This is very simple to use in the frontend for custom forms. Like shown in the example below, it is straight forward to learn how to apply validation. The rules here, can be either a sinle rule and a single json object or an array of rules. In the first inline method uses an array of validation rules and the second method in the init script uses a single json object to apply rules.

The validation happens on each input after clicking outside the input area, if the validation is successful it will show a basic green message. If the validation fails, then it will show a basic red message and add a new class to mark as invalid input value. Once the user fills the form, then upon submitting the form will validate and continue if validation is successful and stops if not.

The rule has rule name which is the validation class, args which are optional and name which is optional to use in the message. The validation results can be overriten by overriding the `Alaa/RvInputValidation/view/frontend/web/js/rv-input-results.js`

Example

```

    Email:
    Age:

        Submit

    {
        "#age": {
        "rv-input-validator": {"rules": {"rule": "between", "args": {"min": 18, "max": 22}}, "name": "Age"}}
    }

```

Contribution
============

[](#contribution)

Feel free to raise issues and contribute

Licence
=======

[](#licence)

MIT

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

3046d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c696bf597ea0fdd1fd166ce20d7c15c873f16547e874bd67ecb70c4abfdb2cb?d=identicon)[alaa-almaliki](/maintainers/alaa-almaliki)

---

Top Contributors

[![alaa-almaliki](https://avatars.githubusercontent.com/u/7830984?v=4)](https://github.com/alaa-almaliki "alaa-almaliki (6 commits)")

### Embed Badge

![Health badge](/badges/alaa-magento2-input-validation/health.svg)

```
[![Health](https://phpackages.com/badges/alaa-magento2-input-validation/health.svg)](https://phpackages.com/packages/alaa-magento2-input-validation)
```

###  Alternatives

[awurth/slim-validation

A wrapper around the respect/validation PHP validation library for easier error handling and display

65378.4k9](/packages/awurth-slim-validation)[progsmile/request-validator

Simple PHP Request Validator

33113.3k1](/packages/progsmile-request-validator)[resultsystems/validation

Inspired 'KennedyTedesco Validation' - The power of 'Respect Validation' on Laravel.

2832.4k4](/packages/resultsystems-validation)

PHPackages © 2026

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