PHP code example of seferov / request-validator-bundle
1. Go to this page and download the library: Download seferov/request-validator-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
seferov / request-validator-bundle example snippets
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",
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Seferov\RequestValidatorBundle\SeferovRequestValidatorBundle(),
);
// ...
}
// ...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.