PHPackages                             softxpert/magento1-validator - 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. softxpert/magento1-validator

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

softxpert/magento1-validator
============================

Laravel like Magento 1.x validator

1.3.1(6y ago)247MITPHP

Since Mar 2Pushed 5y ago1 watchersCompare

[ Source](https://github.com/mohamed-abdul-fattah/magento1-validator)[ Packagist](https://packagist.org/packages/softxpert/magento1-validator)[ RSS](/packages/softxpert-magento1-validator/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (6)Used By (0)

Magento Validator
=================

[](#magento-validator)

> Laravel like Magento 1.x validator.

[![Release](https://camo.githubusercontent.com/d47df15d7e5ea4688d985507f0aa6540d515c946ef4bcca40c5172d97a6cf1a4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656c656173652d312e332e312d626c75652e737667)](https://camo.githubusercontent.com/d47df15d7e5ea4688d985507f0aa6540d515c946ef4bcca40c5172d97a6cf1a4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656c656173652d312e332e312d626c75652e737667)[![License](https://camo.githubusercontent.com/188113d3cd57fe0befefccf2a1835938c1810a7994fbe0e869a59dcb0a0b12e2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d79656c6c6f77677265656e2e737667)](https://camo.githubusercontent.com/188113d3cd57fe0befefccf2a1835938c1810a7994fbe0e869a59dcb0a0b12e2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d79656c6c6f77677265656e2e737667)

Magento validator is a validation service to validate inputs for requests. It depends on Zend validation classes, for more information about these validation rules visit [Zend Documentation](https://framework.zend.com/manual/1.12/en/zend.validate.set.html)

Table of Contents
-----------------

[](#table-of-contents)

1. [Getting Started](#getting-started)
    - [Installation](#installation)
    - [How To](#how-to)
2. [Rules And Methods](#rules-and-methods)
    - [Available Rules](#available-validation-rules)
    - [Available Methods](#available-methods)
3. [Contributing](#contributing)
4. [License](#license)
5. [Change Logs](#changelog)

Getting Started
---------------

[](#getting-started)

### Installation

[](#installation)

Require the Magento validator via composer

```
composer require softxpert/magento1-validator
```

This isntallation will install [modman](https://github.com/colinmollenhour/modman) package to map Magento files from the vendor directory.

Execute the following commands to map the module files into your Magento project

```
vendor/bin/modman init
# If this is the first installation
vendor/bin/modman link vendor/softxpert/magento1-validator
# If this is an update, then we need to re-link the files
vendor/bin/modman repair vendor/softxpert/magento1-validator
# Regenerate autoload files
composer dumpautoload
```

Finally we are done, and you'll find the module files under `app/code/community/Softxpert/Validator` directory.

### How To

[](#how-to)

To validate a request you have 2 ways:

#### Inline Validation

[](#inline-validation)

```
// Create an instance of the validator model
/** @var Softxpert_Validator_Model_Validator $validator */
$vaidator = Mage::getModel('softxpert_validator/validator');
// Preparing validator with data and rules arrays
$data  = $this->getRequest->getParams();
$rules = [
    'username' => 'required|alpha_num',
    'email'    => 'required|string|email',
];
$validator->validate($data, $rules);

// Check whether the data fails or passes
// returns true|false
if ( $validator->fails() ) {
    // Do some stuff
}
```

It supports nested inputs too.

```
$data = [
    'banner' => [
        'url'       => 'some value',
        'link_type' => 'cutom',
        'roles'     => ['admin', 'user'],
        'words'  => [
            [
                'letters' => 789
            ],
            [
                'letters' => 'string'
            ]
        ]
    ]
];

$rules = [
    'banner.url'     => 'string',
    'banner.url'     => 'string|in:valid,custom',
    'banner.roles.*' => 'string',
    'banner.words.*.letters' => 'string',
];

/** @var Softxpert_Validator_Model_Validator $validator */
$vaidator = Mage::getModel('softxpert_validator/validator');
$validator->validate($data, $rules)->redirectOnFailure();
```

#### Observer Validator

[](#observer-validator)

Create an observer for that particular route and handle all your request validations.

For more example usage, visit the [ValidationsTest class](/tests/Unit/ValidationsTest.php).

Rules And Methods
-----------------

[](#rules-and-methods)

### Available Validation Rules

[](#available-validation-rules)

##### alpha

[](#alpha)

String under alpha rule must consist of alphabetic characters.

##### alpha\_num

[](#alpha_num)

String under alpha\_num rule must consist of alphabetic and numeric characters.

##### between:min,max

[](#betweenminmax)

Validates a given value to be between `min` and `max` values.

##### break

[](#break)

Break chain of rules on the first failure.

##### date:format

[](#dateformat)

Validates the given value to equal to a given date format. If format is not given, then the default format `(yyyy-mm-dd)` will be used.

##### digits

[](#digits)

Validates a given value to be numeric.

##### email

[](#email)

Validates a given value to be an email.

##### even

[](#even)

Validate a given value to be an even number.

##### extensions:jpg,png,txt,...

[](#extensionsjpgpngtxt)

Allowed extensions for a particular file input field.

##### float

[](#float)

Validates a given value to be float.

##### gt:min

[](#gtmin)

Validates the given value to be greater than a `min` value.

##### integer

[](#integer)

Validates a given value to be an integer.

##### image

[](#image)

The file under validation must be an image (jpeg, png, bmp, gif, ...)

##### in:foo,bar...

[](#infoobar)

Validates that a given value is one of the provided options.

##### ipv4

[](#ipv4)

Validates the given value to be an IP v4 address.

##### lt:max

[](#ltmax)

Validates the given value to be less than a `max` value.

##### nullable

[](#nullable)

Field under validation is allowed to be null/empty.

##### odd

[](#odd)

Validates a given value to be odd number.

##### regex:pattern

[](#regexpattern)

Validates the given string to match a given pattern. Eg: `regex:/^Test/`

##### required

[](#required)

Field under validation is required.

##### string

[](#string)

Validates that the given value is a string.

##### str\_extension:txt,log,...

[](#str_extensiontxtlog)

Validates that the given file name is in the provided extension set (no MIME type checks).

##### str\_size:min,max

[](#str_sizeminmax)

String size validates a string size with `min` and `max` values. If `min` and `max` are not provided, then the rule validates the value as a string. If only `min` is provided, then the rule validates the minimum string length with unlimited maximum length.

##### zip\_code:locale

[](#zip_codelocale)

Validates the value to be a postal zip code. Locale must be provided. Eg: `zip_code:ar_EG`

### Available Methods

[](#available-methods)

##### validate

[](#validate)

Prepare the validator with data and rules.

```
/**
 * @param  array $data
 * @param  array $rules
 * @return Softxpert_Validator_Model_Validator
 */
public function validate($data, $rules)
```

##### isValid

[](#isvalid)

Checks whether the data are valid or not. If `$fieldName` is provided, then the validation would be applied only on this field.

```
/**
 * @param  string|null $fieldName
 * @return bool
 */
public function isValid($fieldName = null)
```

##### fails

[](#fails)

Checks whether the data fails the validation or not. If `$fieldName` is provided, then the validation would be applied only on this field.

```
/**
 * @param  string|null $fieldName
 * @return bool
 */
public function fails($fieldName = null)
```

##### getMessages

[](#getmessages)

Return validation error messages array under `errors` error bag.

```
/**
 * @return array
 */
public function getMessages()
```

##### getMessagesTemplate

[](#getmessagestemplate)

Return validation error messages in an HTML un-ordered list block.

```
/**
 * @return string
 */
public function getMessagesTemplate()
```

##### redirectOnFailure

[](#redirectonfailure)

End request and return with error messages on validation failure. This method supports both, redirecting to an HTML page with session error messages or JSON response. If `$redirectTo` is not specified, then the request will redirect to the previous page.

```
/**
 * @param  bool $wantsJson
 * @param  string|null $redirectTo
 */
public function redirectOnFailure($wantsJson = false, $redirectTo = null)
```

##### noChain

[](#nochain)

Determine whether the validation errors should break and return on the first in-valid rule, or return a complete set of error messages

```
/**
 * @param  bool $flag
 * @return $this
 */
public function noChain($flag = true)
```

Contributing
------------

[](#contributing)

Please, read [CONTRIBUTING.md](/CONTRIBUTING.md) for details on the process for submitting pull requests to us.

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](/LICENSE) file for details

ChangeLog
---------

[](#changelog)

Please, read the [CHANGELOG.md](/CHANGELOG.md) for more details about releases updates.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 87.5% 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 ~20 days

Total

5

Last Release

2545d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/26ede65d80c85cb7a8df6a00811d3a6e591fb57a252b9a7b8ba2028666a028c1?d=identicon)[csmohamed](/maintainers/csmohamed)

---

Top Contributors

[![mohamed-abdul-fattah](https://avatars.githubusercontent.com/u/9275467?v=4)](https://github.com/mohamed-abdul-fattah "mohamed-abdul-fattah (28 commits)")[![yehiaserag](https://avatars.githubusercontent.com/u/48730547?v=4)](https://github.com/yehiaserag "yehiaserag (4 commits)")

---

Tags

magento-extensionmagento-validatormagento1phpvalidationvalidatorvalidationmagentolaravel like validator

### Embed Badge

![Health badge](/badges/softxpert-magento1-validator/health.svg)

```
[![Health](https://phpackages.com/badges/softxpert-magento1-validator/health.svg)](https://phpackages.com/packages/softxpert-magento1-validator)
```

###  Alternatives

[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[opis/json-schema

Json Schema Validator for PHP

64236.9M186](/packages/opis-json-schema)[vlucas/valitron

Simple, elegant, stand-alone validation library with NO dependencies

1.6k4.4M128](/packages/vlucas-valitron)[intervention/validation

Additional validation rules for the Laravel framework

6826.7M8](/packages/intervention-validation)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[wixel/gump

A fast, extensible &amp; stand-alone PHP input validation class that allows you to validate any data.

1.2k1.3M29](/packages/wixel-gump)

PHPackages © 2026

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