2017 © Pedro Peláez
 

library validator

Slick/Validator is a simple library with useful input validators

image

slick/validator

Slick/Validator is a simple library with useful input validators

  • Tuesday, February 2, 2016
  • by fsilva
  • Repository
  • 2 Watchers
  • 0 Stars
  • 921 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 1 % Grown

The README.md

Slick Validator package

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads, (*1)

Slick/Validator is a set of input validation tools that can be used to check your input data. It also has the concept of Validation Chain that can combine validators for a specific validation., (*2)

This package is compliant with PSR-2 code standards and PSR-4 autoload standards. It also applies the semantic version 2.0.0 specification., (*3)

Install

Via Composer, (*4)

``` bash $ composer require slick/validator, (*5)


## Usage One of the easiest ways of using a validator is using `StaticValidator` class to check a value: ```php use Slick\Validator\StaticValidator; if (StaticValidator::validates('notEmpty', $value) { // Some code with valid value } else { print StaticValidator::getMessage(); // Print out validation messages }

Slick/Validator comes with the following validators:, (*6)

Alias Description Class
notEmpty Fails if passed value is an empty string Slick\Validator\NotEmpty
email Fails if passed value is not a valid e-mail address Slick\Validator\Email
number Fails if passed value is not am integer number Slick\Validator\Number
alphaNumeric Fails if passed value is not an alpha numeric value Slick\Validator\AlphaNumeric
url Fails if passed value is not an URL Slick\Validator\URL

StaticValidator is also a validator objects factory. For example:, (*7)

use Slick\Validator\StaticValidator;

$urlValidator = StaticValidator::create('notEmpty', 'You must enter a valid URL.');

if ($urlValidator->validates($_POST['url']) {
    // URL is valid use it...
} else {
    print $urlValidator->getMessage(); // Will print out 'You must enter a valid URL.'
}

Combining various validator to use it as a single validation can be done with ValidationChain., (*8)

use Slick\Validator\StaticValidator;
use Slick\Validator\ValidationChain;

$emailValidation = new ValidationChain();
$emailValidation
    ->add(StaticValidator::create('notEmpty', 'Email address cannot be empty.'))
    ->add(StaticValidator::create('email', 'The entered e-mail is not a valid address.');

if ($emailValidation->validates($_POST['email']) {
    // URL is valid use it...
} else {
    print implode(', ', $emailValidation->getMessages()); 
    // Will print out the validation messages for the validator(s) that fail.
}    

You can always create your own validator and use the StaticValidator or the ValidationChain as long as you implement the Slick\Validator\ValidatorInterface or Slick\Validator\ValidationChainInterface., (*9)

Testing

bash $ vendor/bin/phpunit, (*10)

Contributing

Please see CONTRIBUTING for details., (*11)

Security

If you discover any security related issues, please email silvam.filipe@gmail.com instead of using the issue tracker., (*12)

Credits

License

The MIT License (MIT). Please see License File for more information., (*13)

The Versions

02/02 2016

dev-develop

dev-develop https://github.com/slickframework/validator

Slick/Validator is a simple library with useful input validators

  Sources   Download

MIT

The Requires

 

The Development Requires

validation slick input validation

02/02 2016

dev-master

9999999-dev https://github.com/slickframework/validator

Slick/Validator is a simple library with useful input validators

  Sources   Download

MIT

The Requires

 

The Development Requires

validation slick input validation

02/02 2016

v1.1.0

1.1.0.0 https://github.com/slickframework/validator

Slick/Validator is a simple library with useful input validators

  Sources   Download

MIT

The Requires

 

The Development Requires

validation slick input validation

01/02 2016

v1.0.4

1.0.4.0 https://github.com/slickframework/validator

Slick/Validator is a simple library with useful input validators

  Sources   Download

MIT

The Requires

 

The Development Requires

validation slick input validation