<commit_before># Phalcon Validators

## Introduction

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

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

## 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 example:

### IpValidator

The IpValidator validates a valid ip address.

```php
$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
    <commit_msg>Added badges to readme and bump version to 1.5<commit_after># Phalcon Validators

[![License](https://poser.pugx.org/michele-angioni/phalcon-validators/license)](https://packagist.org/packages/michele-angioni/phalcon-validators)
[![Latest Stable Version](https://poser.pugx.org/michele-angioni/phalcon-validators/v/stable)](https://packagist.org/packages/michele-angioni/phalcon-validators)
[![Latest Unstable Version](https://poser.pugx.org/michele-angioni/phalcon-validators/v/unstable)](https://packagist.org/packages/michele-angioni/phalcon-validators)
[![Build Status](https://travis-ci.org/micheleangioni/phalcon-validators.svg)](https://travis-ci.org/micheleangioni/phalcon-validators)


## Introduction

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

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

## 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 example:

### IpValidator

The IpValidator validates a valid ip address.

```php
$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
    
{'fraction_non_alphanumeric': 0.11928934010152284, 'fraction_numerical': 0.0029006526468455403, 'mean_word_length': 4.176360225140713, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '552862', 'n_tokens_mistral': 860, 'n_tokens_neox': 822, 'n_words': 243}