https://github.com/respect/validationbundle
A Respect\Validation Bundle for Symfony
https://github.com/respect/validationbundle
Last synced: 4 months ago
JSON representation
A Respect\Validation Bundle for Symfony
- Host: GitHub
- URL: https://github.com/respect/validationbundle
- Owner: Respect
- License: bsd-3-clause
- Created: 2013-01-28T12:45:13.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2015-06-10T21:01:19.000Z (over 10 years ago)
- Last Synced: 2025-06-04T16:26:10.967Z (8 months ago)
- Language: PHP
- Size: 226 KB
- Stars: 17
- Watchers: 9
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ValidationBundle
[](https://travis-ci.org/Respect/ValidationBundle?branch=develop)
[](https://packagist.org/packages/respect/validation-bundle)
[](https://packagist.org/packages/respect/validation-bundle)
[](https://packagist.org/packages/respect/validation-bundle)
[](https://packagist.org/packages/respect/validation-bundle)
A Respect\Validation Bundle for Symfony
## Installation
Package is available on [Packagist](http://packagist.org/packages/respect/validation-bundle),
you can install it using [Composer](http://getcomposer.org).
```shell
composer require respect/validation-bundle
```
Add the bundle to your AppKernel.php:
```php
public function registerBundles()
{
return array(
// ...
new Respect\ValidationBundle\RespectValidationBundle(),
// ...
);
}
```
## Usage
### Use as service `respect.validator`
```php
//...
class AcmeController extends Controller
{
public function indexAction()
{
$number = 123;
$isValid = $this->get('respect.validator')->numeric()->validate($number);//true
//...
```
### Use as alias
```php
//...
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
//...
```