A Respect\Validation Bundle for Symfony
PHP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
DependencyInjection
Resources/config
Tests/Validator/Constraints
Validator
.travis.yml
LICENSE
README.md
RespectValidationBundle.php
composer.json
phpunit.xml.dist

README.md

ValidationBundle

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

A Respect\Validation Bundle for Symfony

Installation

Package is available on Packagist, you can install it using Composer.

composer require respect/validation-bundle

Add the bundle to your AppKernel.php:

public function registerBundles()
{
    return array(
        // ...
        new Respect\ValidationBundle\RespectValidationBundle(),
        // ...
    );
}

Usage

Use as service respect.validator

//...
class AcmeController extends Controller
{
    public function indexAction()
    {
        $number = 123;
        $isValid = $this->get('respect.validator')->numeric()->validate($number);//true
//...

Use as alias

//...

use Respect\Validation\Validator as v;

class AcmeController extends Controller
{
    public function indexAction()
    {
        $validUsername = v::alnum()
            ->noWhitespace()
            ->length(1,15);

        $isValid = $validUsername->validate('alganet'); //true
        //...