RespectValidationBundle is a project mainly written in PHP, it's free.
Symfony 2 Bundle for the most awesome validation engine ever created for PHP
1. Fix false validation on service
Add reps to your deps file:
[RespectValidationBundle]
git=git://github.com/gpupo/RespectValidationBundle.git
target=bundles/Respect/ValidationBundle
[RespectValidation]
git=git://github.com/Respect/Validation.git
target=Respect/Validation
run bin/vendors install
)
Register the namespace Respect
to your project's autoloader bootstrap script:
//app/autoload.php
$loader->registerNamespaces(array(
// ...
'Respect' => __DIR__.'/../vendor/Respect/Validation/library',
// ...
));
4 Add this bundle to your application's kernel:
//app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Respect\ValidationBundle\RespectValidationBundle(),
// ...
);
}
unstable
): //...
class HomeController extends Controller
{
public function indexAction()
{
$number = 123;
$x = $this->get('respect.validator')->numeric()->validate($number);//true
//...
<?php
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Respect\Validation\Validator as v;
class HomeController extends Controller
{
public function indexAction()
{
$validUsername = v::alnum()
->noWhitespace()
->length(1,15);
$x = $validUsername->validate('alganet'); //true
//...
See documentation on https://github.com/Respect/Validation