2017 © Pedro Peláez
 

library validator

A validator on top of Symfony validator

image

ebidtech/validator

A validator on top of Symfony validator

  • Thursday, February 13, 2014
  • by ebidtech
  • Repository
  • 13 Watchers
  • 0 Stars
  • 48,070 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Validator

A validator on top of Symfony validator., (*1)

Latest Stable Version Build Status Coverage Status Scrutinizer Quality Score Dependency Status, (*2)

Why to use?

Using Symfony validator with annotations or configuration (yml or xml) is just fine, but for simple cases, eg: validation of argument methods and throw exception is too verbose., (*3)

Eg:, (*4)

Symfony way

use Symfony\Component\Validator\Validation;
use Symfony\Component\Validator\Constraints\Type;

class Test {
    public function getByName($name)
    {
        $violations = Validation::createValidator()->validateValue(
            $name,
            new Type(array('type' => 'string'))
        );

        if (count($violations) != 0) {
          throw new \InvalidArgumentException((string) $violations);
        }
    }
}

EBTValidator way

use EBT\Validator\ValidatorBasicExtended;

class Test {
    public function getByName($name)
    {
        if (!ValidatorBasicExtended::isTypeString($name)) {
            throw new \InvalidArgumentException(ValidatorBasicExtended::getViolationsAsShortString());
        }
    }
}

Requirements

  • PHP >= 5.3.3

Installation

The recommended way to install is through composer., (*5)

Just create a composer.json file for your project:, (*6)

{
    "require": {
        "ebidtech/validator": "@stable"
    }
}

Tip: browse ebidtech/validator page to choose a stable version to use, avoid the @stable meta constraint., (*7)

And run these two commands to install it:, (*8)

$ curl -sS https://getcomposer.org/installer | php
$ composer install

Now you can add the autoloader, and you will have access to the library:, (*9)

<?php

require 'vendor/autoload.php';

Usage

The validators are divided according to the Symfony Validator:, (*10)

  • ValidatorBasic
  • ValidatorString
  • ValidatorNumber
  • ValidatorDate
  • ValidatorCollection

For each one exists a Extended version (Eg: ValidatorBasicExtended), that adds convenience alias methods. It exists also a ValidatorExtended that mix validations., (*11)

Example of code, (*12)

Contributing

See CONTRIBUTING file., (*13)

Credits

License

Validator library is released under the MIT License. See the bundled LICENSE file for details., (*14)

The Versions

13/02 2014

dev-master

9999999-dev http://github.com/ebidtech/validator

A validator on top of Symfony validator

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ebidtech

php library validator symfony

13/02 2014

v0.1.4.1

0.1.4.1 http://github.com/ebidtech/validator

A validator on top of Symfony validator

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ebidtech

php library validator symfony

13/02 2014

dev-eb-636-categories-bid-value-per-list

dev-eb-636-categories-bid-value-per-list http://github.com/ebidtech/validator

A validator on top of Symfony validator

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ebidtech

php library validator symfony

13/02 2014

v0.1.4

0.1.4.0 http://github.com/ebidtech/validator

A validator on top of Symfony validator

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ebidtech

php library validator symfony

25/01 2014

v0.1.3.1

0.1.3.1 http://github.com/ebidtech/validator

A validator on top of Symfony validator

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ebidtech

php library validator symfony

16/01 2014

v0.1.3

0.1.3.0 http://github.com/ebidtech/validator

A validator on top of Symfony validator

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ebidtech

php library validator symfony

15/01 2014

v0.1.2

0.1.2.0 http://github.com/ebidtech/validator

A validator on top of Symfony validator

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ebidtech

php library validator symfony

13/01 2014

v0.1.1

0.1.1.0 http://github.com/ebidtech/validator

A validator on top of Symfony validator

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ebidtech

php library validator symfony

12/01 2014

v0.1

0.1.0.0 http://github.com/ebidtech/validator

A validator on top of Symfony validator

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ebidtech

php library validator symfony