PHPackages                             michele-angioni/phalcon-validators - 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. michele-angioni/phalcon-validators

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

michele-angioni/phalcon-validators
==================================

New advanced validators for PHP Phalcon Framework.

v2.0.1(8y ago)83.9k1MITPHPPHP &gt;=7.1

Since May 2Pushed 8y ago4 watchersCompare

[ Source](https://github.com/micheleangioni/phalcon-validators)[ Packagist](https://packagist.org/packages/michele-angioni/phalcon-validators)[ RSS](/packages/michele-angioni-phalcon-validators/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (2)Versions (16)Used By (0)

Phalcon Validators
==================

[](#phalcon-validators)

[![License](https://camo.githubusercontent.com/ab5efcfc3428c527e3d1e502ebbd7695ace19e0b0230cb4e83b6296c3e9bb942/68747470733a2f2f706f7365722e707567782e6f72672f6d696368656c652d616e67696f6e692f7068616c636f6e2d76616c696461746f72732f6c6963656e7365)](https://packagist.org/packages/michele-angioni/phalcon-validators)[![Latest Stable Version](https://camo.githubusercontent.com/821275201b1ac9dad11fde9609a64a16ae2e8a35530d215456d0513ee36ce1fc/68747470733a2f2f706f7365722e707567782e6f72672f6d696368656c652d616e67696f6e692f7068616c636f6e2d76616c696461746f72732f762f737461626c65)](https://packagist.org/packages/michele-angioni/phalcon-validators)[![Latest Unstable Version](https://camo.githubusercontent.com/43ea77ec3ef5e79152ed8c9397a3cb5371dbafc1426ad149144c5177e7431c39/68747470733a2f2f706f7365722e707567782e6f72672f6d696368656c652d616e67696f6e692f7068616c636f6e2d76616c696461746f72732f762f756e737461626c65)](https://packagist.org/packages/michele-angioni/phalcon-validators)[![Build Status](https://camo.githubusercontent.com/13ab6f3f14564fa1f7717b0e006f33044829e3e6ac093478d284f66233dba562/68747470733a2f2f7472617669732d63692e6f72672f6d696368656c65616e67696f6e692f7068616c636f6e2d76616c696461746f72732e737667)](https://travis-ci.org/micheleangioni/phalcon-validators)

Introduction
------------

[](#introduction)

Phalcon Validators adds several new validators to the few default ones present in Phalcon.

PHP 7.1+ and Phalcon 3.1 are required.

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

[](#installation)

Support can be installed through Composer, just include `"michele-angioni/phalcon-validators": "~2.0"` to your composer.json and run `composer update` or `composer install`.

Usage
-----

[](#usage)

The new validators work in the same way the default validators do. Just pass a new instance of the validator to the Phalcon `Validation` class, with the desired options, and then validate it.

Available validators with practical examples:

### IpValidator

[](#ipvalidator)

The IpValidator validates a valid ip address.

```
$data['ip'] = $this->request->getPost('ip');

$validation = new Phalcon\Validation();

$validation->add(
    'ip',
    new MicheleAngioni\PhalconValidators\IpValidator (
        [
            'message' => 'The IP is not valid.'       // Optional
        ]
    )
);

$messages = $validation->validate($data);

if (count($messages)) {
    // Some error occurred, handle messages

}
```

// Validation succeeded without errors

### NumericValidator

[](#numericvalidator)

The default NumericValidator only allows for numeric (i.e. 0-9) characters. Minimum and maximum values can be specified.

Optionally, it can support float values, that is allowing a dot (.) character to separate decimals.

Optionally also signed numbers are supported.

```
$data['number'] = $this->request->getPost('number');

$validation = new Phalcon\Validation();

$validation->add(
    'number',
    new MicheleAngioni\PhalconValidators\NumericValidator (
        [
            'allowFloat' => true,                                           // Optional, default: false
            'allowSign' => true,                                            // Optional, default: false
            'min' => 2,                                                     // Optional
            'min' => 2,                                                     // Optional
            'max' => 50,                                                    // Optional
            'message' => 'Only numeric (0-9,.) characters are allowed.',    // Optional
            'messageMinimum' => 'The value must be at least 2',             // Optional
            'messageMaximum' => 'The value must be lower than 50'           // Optional
        ]
    )
);

$messages = $validation->validate($data);

if (count($messages)) {
    // Some error occurred, handle messages

}

// Validation succeeded without errors
```

### AlphaNumericValidator

[](#alphanumericvalidator)

The AlphaNumericValidator allows for alphanumeric characters. Optionally, it can allow underscores, minuses and white spaces. Minimum and maximum string lengths can be specified.

```
$data['text'] = $this->request->getPost('text');

$validation = new Phalcon\Validation();

$validation->add(
    'text',
    new MicheleAngioni\PhalconValidators\AlphaNumericValidator (
        [
            'whiteSpace' => true,                                                       // Optional, default false
            'underscore' => true,                                                       // Optional, default false
            'minus' => true,                                                            // Optional, default false
            'min' => 6,                                                                 // Optional
            'max' => 30,                                                                // Optional
            'message' => 'Validation failed.',                                          // Optional
            'messageMinimum' => 'The value must contain at least 6 characters.',        // Optional
            'messageMaximum' => 'The value can contain maximum 30 characters.'          // Optional
        ]
    )
);

$messages = $validation->validate($data);

if (count($messages)) {
    // Some error occurred, handle messages

}

// Validation succeeded without errors
```

### AlphaNamesValidator

[](#alphanamesvalidator)

The AlphaNamesValidator allows for alphabetic, menus, apostrophe, underscore and white space characters. Optionally, it can allow also numbers (i.t. 0-9). Minimum and maximum string lengths can be specified.

```
$data['text'] = $this->request->getPost('text');

$validation = new Phalcon\Validation();

$validation->add(
    'text',
    new MicheleAngioni\PhalconValidators\AlphaNamesValidator (
        [
            'numbers' => true,                                                          // Optional, default false
            'min' => 6,                                                                 // Optional
            'max' => 30,                                                                // Optional
            'message' => 'Validation failed.',                                          // Optional
            'messageMinimum' => 'The value must contain at least 6 characters.',        // Optional
            'messageMaximum' => 'The value can contain maximum 30 characters.'          // Optional
        ]
    )
);

$messages = $validation->validate($data);

if (count($messages)) {
    // Some error occurred, handle messages

}

// Validation succeeded without errors
```

### AlphaCompleteValidator

[](#alphacompletevalidator)

The AlphaCompleteValidator allows for alphanumeric, underscore, white space, slash, apostrophe, round and square brackets/parentheses and punctuation characters. Optionally, it can allow also pipes (|), ATs (@), backslashes (), percentages (%) and Url Characters (equals (=) and hashtags (#)). Minimum and maximum string lengths can be specified.

```
$data['text'] = $this->request->getPost('text');

$validation = new Phalcon\Validation();

$validation->add(
    'text',
    new MicheleAngioni\PhalconValidators\AlphaCompleteValidator (
        [
            'allowBackslashes' => true,                                                 // Optional
            'allowAt' => true,                                                          // Optional
            'allowPipes' => true,                                                       // Optional
            'allowPercentages' => true,                                                 // Optional
            'allowUrlChars' => true,                                                    // Optional
            'min' => 6,                                                                 // Optional
            'max' => 30,                                                                // Optional
            'message' => 'Validation failed.',                                          // Optional
            'messageMinimum' => 'The value must contain at least 6 characters.',        // Optional
            'messageMaximum' => 'The value can contain maximum 30 characters.'          // Optional
        ]
    )
);

$messages = $validation->validate($data);

if (count($messages)) {
    // Some error occurred, handle messages

}

// Validation succeeded without errors
```

### FileNameValidator

[](#filenamevalidator)

The FileNameValidator allows for a valid file name with extension, allowing simple letters, numbers underscores and minuses. Optionally, it can allow also all Latin characters, multiple dots and white spaces. Minimum and maximum string lengths can be specified.

```
$data['text'] = $this->request->getPost('text');

$validation = new Phalcon\Validation();

$validation->add(
    'text',
    new MicheleAngioni\PhalconValidators\FileNameValidator (
        [
            'allowMultipleDots' => true,                                                // Optional
            'allowAllLatin' => true,                                                    // Optional
            'allowSpaces' => true,                                                      // Optional
            'min' => 6,                                                                 // Optional
            'max' => 30,                                                                // Optional
            'message' => 'Validation failed.',                                          // Optional
            'messageMinimum' => 'The value must contain at least 6 characters.',        // Optional
            'messageMaximum' => 'The value can contain maximum 30 characters.'          // Optional
        ]
    )
);

$messages = $validation->validate($data);

if (count($messages)) {
    // Some error occurred, handle messages

}

// Validation succeeded without errors
```

Contribution guidelines
-----------------------

[](#contribution-guidelines)

Phalcon Validators follows PSR-1, PSR-2 and PSR-4 PHP coding standards, and semantic versioning.

Pull requests are welcome.

License
-------

[](#license)

Phalcon Validators is free software distributed under the terms of the MIT license.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

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

Every ~43 days

Recently: every ~52 days

Total

15

Last Release

3101d ago

Major Versions

v1.7 → v2.02017-10-25

PHP version history (2 changes)v1.0PHP &gt;=5.5

v2.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/8ecc70cee36d2415684680df6e8278c83fc1345dd982bc59296bd8b0b4515160?d=identicon)[Michele](/maintainers/Michele)

---

Top Contributors

[![micheleangioni](https://avatars.githubusercontent.com/u/7933034?v=4)](https://github.com/micheleangioni "micheleangioni (46 commits)")

---

Tags

phalconphalcon-validatorsphpvalidationphalconvalidators

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/michele-angioni-phalcon-validators/health.svg)

```
[![Health](https://phpackages.com/badges/michele-angioni-phalcon-validators/health.svg)](https://phpackages.com/packages/michele-angioni-phalcon-validators)
```

###  Alternatives

[bryglen/yii2-validators

credit card validation yii 2

1426.9k](/packages/bryglen-yii2-validators)

PHPackages © 2026

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