2017 © Pedro Peláez
 

library phalcon-validators

New advanced validators for PHP Phalcon Framework.

image

michele-angioni/phalcon-validators

New advanced validators for PHP Phalcon Framework.

  • Tuesday, January 2, 2018
  • by Michele
  • Repository
  • 4 Watchers
  • 4 Stars
  • 402 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 16 Versions
  • 5 % Grown

The README.md

Phalcon Validators

License Latest Stable Version Latest Unstable Version Build Status, (*1)

Introduction

Phalcon Validators adds several new validators to the few default ones present in Phalcon., (*2)

PHP 7.1+ and Phalcon 3.1 are required., (*3)

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., (*4)

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., (*5)

Available validators with practical examples:, (*6)

IpValidator

The IpValidator validates a valid ip address., (*7)

$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, (*8)

NumericValidator

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

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

Optionally also signed numbers are supported., (*11)

$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

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

$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

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., (*13)

$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

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., (*14)

$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

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., (*15)

$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

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

Pull requests are welcome., (*17)

License

Phalcon Validators is free software distributed under the terms of the MIT license., (*18)

The Versions

02/01 2018

dev-master

9999999-dev

New advanced validators for PHP Phalcon Framework.

  Sources   Download

MIT

The Requires

  • php >=7.1
  • ext-phalcon >=3.1.2

 

The Development Requires

phalcon validators

02/01 2018

v2.0.1

2.0.1.0

New advanced validators for PHP Phalcon Framework.

  Sources   Download

MIT

The Requires

  • php >=7.1
  • ext-phalcon >=3.1.2

 

The Development Requires

phalcon validators

25/10 2017

v2.0

2.0.0.0

New advanced validators for PHP Phalcon Framework.

  Sources   Download

MIT

The Requires

  • php >=7.1
  • ext-phalcon >=3.1.2

 

The Development Requires

phalcon validators

20/09 2017

v1.7

1.7.0.0

New advanced validators for Phalcon.

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-phalcon >=2.0.0

 

The Development Requires

phalcon validators

20/07 2017

v1.6

1.6.0.0

New advanced validators for Phalcon.

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-phalcon >=2.0.0

 

The Development Requires

phalcon validators

07/06 2017

v1.5.1

1.5.1.0

New advanced validators for Phalcon.

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-phalcon >=2.0.0

 

The Development Requires

phalcon validators

01/06 2017

v1.5

1.5.0.0

New advanced validators for Phalcon.

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-phalcon >=2.0.0

 

The Development Requires

phalcon validators

19/03 2017

v1.4.1

1.4.1.0

New advanced validators for Phalcon.

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-phalcon >=2.0.0

 

The Development Requires

phalcon validators

17/12 2016

v1.4

1.4.0.0

New advanced validators for Phalcon.

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-phalcon >=2.0.0

 

The Development Requires

phalcon validators

11/12 2016

v1.3

1.3.0.0

New advanced validators for Phalcon.

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-phalcon >=2.0.0

 

The Development Requires

phalcon validators

19/09 2016

v1.2

1.2.0.0

New advanced validators for Phalcon.

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-phalcon >=2.0.0

 

The Development Requires

phalcon validators

21/07 2016

v1.1.2

1.1.2.0

New advanced validators for Phalcon.

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-phalcon >=2.0.0

 

The Development Requires

phalcon validators

17/07 2016

v1.1.1

1.1.1.0

New advanced validators for Phalcon.

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-phalcon >=2.0.0

 

The Development Requires

phalcon validators

12/07 2016

v1.1

1.1.0.0

New advanced validators for Phalcon.

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-phalcon >=2.0.0

 

The Development Requires

phalcon validators

29/06 2016

v1.0.1

1.0.1.0

New advanced validators for Phalcon.

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-phalcon >=2.0.0

 

The Development Requires

phalcon validators

02/05 2016

v1.0

1.0.0.0

New advanced validators for Phalcon.

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-phalcon >=2.0.0

 

The Development Requires

phalcon validators