2017 © Pedro Peláez
 

symfony-bundle request-validator-bundle

Validates request params with Controller annotations

image

seferov/request-validator-bundle

Validates request params with Controller annotations

  • Sunday, June 17, 2018
  • by ferhad
  • Repository
  • 2 Watchers
  • 5 Stars
  • 8,304 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 21 Versions
  • 11 % Grown

The README.md

Symfony RequestValidatorBundle

Build Status, (*1)

Usage

<?php

namespace AppBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Validator\Constraints as Assert;
use Seferov\RequestValidatorBundle\Validator\RequestValidator;
use Seferov\RequestValidatorBundle\Annotation\Validator;

class AcmeController extends Controller
{
    /**
     * @Validator(name="page", default="1", constraints={@Assert\Type(type="numeric"), @Assert\Range(min=1)})
     * @Validator(name="limit", default="25", constraints={@Assert\Type(type="numeric"), @Assert\Range(min=10, max=100)})
     * @Validator(name="order", default="desc", constraints={@Assert\Choice(choices={"asc", "desc"}, message="error.wrong_order_choice")})
     * @Validator(name="name", constraints={@Assert\NotBlank()})
     * @Validator(name="email", required=true, constraints={@Assert\Email()})
     *
     * @param RequestValidator $requestValidator
     */
    public function someAction(RequestValidator $requestValidator)
    {
        // You can get errors if there is any
        /** @var \Symfony\Component\Validator\ConstraintViolationList $errors */
        $errors = $requestValidator->getErrors();

        // You can get the request value with `get($path)` method
        $email = $requestValidator->get('email');

        // ...
    }
}

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*2)

$ composer require seferov/request-validator-bundle

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*3)

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:, (*4)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Seferov\RequestValidatorBundle\SeferovRequestValidatorBundle(),
        );

        // ...
    }

    // ...
}

The Versions

17/06 2018

dev-master

9999999-dev

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

The Development Requires

17/06 2018

v0.3.0

0.3.0.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

The Development Requires

03/05 2017

v0.2.9

0.2.9.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

The Development Requires

18/04 2017

v0.2.8

0.2.8.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

The Development Requires

17/04 2017

v0.2.7

0.2.7.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

The Development Requires

11/04 2017

v0.2.6

0.2.6.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

The Development Requires

11/04 2017

v0.2.5

0.2.5.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

The Development Requires

15/08 2016

v0.2.4

0.2.4.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

15/08 2016

v0.2.3

0.2.3.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

12/08 2016

v0.2.2

0.2.2.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

12/08 2016

v0.2.1

0.2.1.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

05/08 2016

v0.2.0

0.2.0.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

05/08 2016

v0.1.8

0.1.8.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

01/08 2016

v0.1.7

0.1.7.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

11/07 2016

v0.1.6

0.1.6.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

23/06 2016

v0.1.5

0.1.5.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

23/06 2016

v0.1.4

0.1.4.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

22/06 2016

v0.1.3

0.1.3.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

17/06 2016

v0.1.2

0.1.2.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

17/06 2016

v0.1.1

0.1.1.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires

 

17/06 2016

v0.1.0

0.1.0.0

Validates request params with Controller annotations

  Sources   Download

MIT

The Requires