PHPackages                             nebumix/rt-validation-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. nebumix/rt-validation-bundle

ActiveSymfony-bundle[Validation &amp; Sanitization](/categories/validation)

nebumix/rt-validation-bundle
============================

real time backend validation for Symfony2

017[1 PRs](https://github.com/Nebumix/NeburtValidationBundle/pulls)PHP

Since Sep 29Pushed 11y ago1 watchersCompare

[ Source](https://github.com/Nebumix/NeburtValidationBundle)[ Packagist](https://packagist.org/packages/nebumix/rt-validation-bundle)[ RSS](/packages/nebumix-rt-validation-bundle/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Nebumix/NeburtValidationBundle
==============================

[](#nebumixneburtvalidationbundle)

A real time backend validation for Symfony2

Installation
------------

[](#installation)

### Add bundle to your composer.json file

[](#add-bundle-to-your-composerjson-file)

```
// composer.json

{
    "require": {
        // ...
        "nebumix/rt-validation-bundle": "dev-master"
    }
}
```

### Add bundle to your application kernel

[](#add-bundle-to-your-application-kernel)

```
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Bmatzner\JQueryBundle\BmatznerJQueryBundle(),
        new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
        new Nebumix\rtValidationBundle\NebumixrtValidationBundle(),
        // ...
    );
}
```

### Download the bundle using Composer

[](#download-the-bundle-using-composer)

```
$ php composer.phar update nebumix/rt-validation-bundle
```

### Register the routing definition in `app/config/routing.yml`:

[](#register-the-routing-definition-in-appconfigroutingyml)

```
# app/config/routing.yml
fos_js_routing:
    resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"

Nebumix_rtV_routing:
    resource: "@NebumixrtValidationBundle/Resources/config/routing.yml"
```

### Install assets

[](#install-assets)

Given your server's public directory is named "web", install the public vendor resources

```
$ php app/console assets:install web
```

Optionally, use the --symlink attribute to create links rather than copies of the resources

```
$ php app/console assets:install --symlink web
```

### Create new file `app/config/securityRT.yml`:

[](#create-new-file-appconfigsecurityrtyml)

```
# app/config/securityRT.yml
parameters:
    nebumix_rtvalidation.check.class: Nebumix\rtValidationBundle\Controller\CheckController
```

### Import the new file in `app/config/config.yml`:

[](#import-the-new-file-in-appconfigconfigyml)

```
# app/config/config.yml
imports:
    // ...
    - { resource: securityRT.yml }
```

#### Installing NeburtValidation, you installed automatically also [`bmatzner/jquery-bundle`](https://github.com/bmatzner/BmatznerJQueryUIBundle) and [`friendsofsymfony/jsrouting-bundle`](https://github.com/FriendsOfSymfony/FOSJsRoutingBundle)

[](#installing-neburtvalidation-you-installed-automatically-also-bmatznerjquery-bundle-and-friendsofsymfonyjsrouting-bundle)

##### We need to configure friendsofsymfony/jsrouting-bundle, you can look the official documentation in the official page.

[](#we-need-to-configure-friendsofsymfonyjsrouting-bundle-you-can-look-the-official-documentation-in-the-official-page)

I suggest to add these lines in `app/config/config.yml`:

```
# app/config/config.yml
fos_js_routing:
    routes_to_expose: [ nebumixrt_validation_check ]
```

The route name you need is `nebumixrt_validation_check`

Usage
-----

[](#usage)

#### Add jQuery

[](#add-jquery)

Add this line in your layout:

```

```

#### Add FOSJsRoutingBundle

[](#add-fosjsroutingbundle)

Add these two lines in your layout:

```

```

#### Add rtValidation

[](#add-rtvalidation)

Add this line in your layout:

```

```

#### Write javascript functions

[](#write-javascript-functions)

This example supposed to have in the page a form with fields called `nameField`, `nameField1` ... It will be explain better in the example.

To validate in real time a form field, you need to call a function to check your field. I use the .focusout function.

To validate a text field you need to add in your layout:

```
$(function() {
	$('#nameForm_nameField').focusout(function() {
		check_field('nameValidation', 'nameForm_nameField');
	});
	$('#nameForm_nameField1').focusout(function() {
		check_field('nameValidation', 'nameForm_nameField1');
	});

	//...

	$('#nameForm_nameFieldN').focusout(function() {
		check_field('nameValidation', 'nameForm_nameFieldN');
	});

	//if you have a radio or checkbox
	$('#nameForm_nameFieldN').onchange(function() {
		check_field_check('nameValidation', 'nameFieldToCheck');
	});

});
```

You need to replace `nameField` with the field name you want to validate and `nameForm` with the form name (generally the id field is made using nameForm\_nameField). You need to replace `nameValidation` with a name, it must to be different for each form. Is not necessary `nameValidation` is the real form name, it needs just to distinguish the form fields in the validation file.

#### Write validation rules in `securityRT.yml`:

[](#write-validation-rules-in-securityrtyml)

```
parameters:
    nebumix_rtvalidation.check.class: Nebumix\rtValidationBundle\Controller\CheckController
    nameValidation:
        nameForm_nameField:
            NotBlank:
                message: Field is required.
            Regex:
                pattern: "/^\d+$/"
                message: insert an integer
        nameForm_nameField1:
            NotBlank:
            Length:
                min: 3
        nameFieldToCheck:
            NotBlank:
```

You have to use the name you used as `nameValidation` in the javascript function followed by the name used as `nameForm_nameField` and by the validation rules, as you can see in the example.

### Print errors

[](#print-errors)

To print errors you can add in your layout:

```

/ ...

```

The div id must to have the `nameForm_nameField` followed by `_error`. You have to write one for each field.

### Send the form

[](#send-the-form)

Now you can validate your form in real time, but if you like stopping the form if the validation returns errors, add the javascript function in your layout:

```
$( document ).ready(function() {
	$( "#sendForm" ).click(function() {

		//list functions, each per field
		var c_nameField = check_field('nameValidation', 'nameForm_nameField');
		var c_nameField1 = check_field('nameValidation', 'nameForm_nameField1');
		//..
		var c_nameFieldN = check_field('nameValidation', 'nameForm_nameFieldN');

		//if you have a radio or checkbox
		var c_nameFieldToCheck = check_field_check('nameValidation', 'nameFieldToCheck');

		if( c_nameField == 1 && c_nameField1 == 1 )
		{
			var form_data = $('#myForm').serialize();

		      $.ajax({
        		url: Routing.generate('_your_route_to_save_form'),
		        type: "POST",
		        data:  form_data,
		        dataType: "html",
		        async : false,
		        success: function(msg) {
				//if the function have no error return 1
		                if(msg == 1){
					alert('Saved');
		                }else{
					check_field('nameValidation', 'nameForm_nameField');
					check_field('nameValidation', 'nameForm_nameField1');
					//...
					check_field('nameValidation', 'nameForm_nameFieldN');
				}
		        },
		        error: function(){
		          alert("ERROR!");
		        }
		    });

		}
	});
});
```

This is just an example, you can write your own function.

### Supported Constraints:

[](#supported-constraints)

#### Basic Constraints

[](#basic-constraints)

- [`NotBlank`](http://symfony.com/doc/current/reference/constraints/NotBlank.html)
- [`Blank`](http://symfony.com/doc/current/reference/constraints/Blank.html)
- [`NotNull`](http://symfony.com/doc/current/reference/constraints/NotNull.html)
- [`Null`](http://symfony.com/doc/current/reference/constraints/Null.html)
- [`Type`](http://symfony.com/doc/current/reference/constraints/Type.html)

#### String Constraints

[](#string-constraints)

- [`Email`](http://symfony.com/doc/current/reference/constraints/Email.html)
- [`Length`](http://symfony.com/doc/current/reference/constraints/Length.html)
- [`Url`](http://symfony.com/doc/current/reference/constraints/Url.html)
- [`Regex`](http://symfony.com/doc/current/reference/constraints/Regex.html)
- [`Ip`](http://symfony.com/doc/current/reference/constraints/Ip.html)
- [`Uuid (>=2.5)`](http://symfony.com/doc/current/reference/constraints/Uuid.html)

#### Number Constraints

[](#number-constraints)

- [`Range`](http://symfony.com/doc/current/reference/constraints/Range.html)

#### Comparison Constraints

[](#comparison-constraints)

- [`EqualTo`](http://symfony.com/doc/current/reference/constraints/EqualTo.html)
- [`NotEqualTo`](http://symfony.com/doc/current/reference/constraints/NotEqualTo.html)
- [`IdenticalTo`](http://symfony.com/doc/current/reference/constraints/IdenticalTo.html)
- [`NotIdenticalTo`](http://symfony.com/doc/current/reference/constraints/NotIdenticalTo.html)
- [`LessThan`](http://symfony.com/doc/current/reference/constraints/LessThan.html)
- [`LessThanOrEqual`](http://symfony.com/doc/current/reference/constraints/LessThanOrEqual.html)
- [`GreaterThan`](http://symfony.com/doc/current/reference/constraints/GreaterThan.html)
- [`GreaterThanOrEqual`](http://symfony.com/doc/current/reference/constraints/GreaterThanOrEqual.html)

#### Date Constraints

[](#date-constraints)

- [`Date`](http://symfony.com/doc/current/reference/constraints/Date.html)
- [`DateTime`](http://symfony.com/doc/current/reference/constraints/DateTime.html)
- [`Time`](http://symfony.com/doc/current/reference/constraints/Time.html)

#### Financial and other Number Constraints

[](#financial-and-other-number-constraints)

- [`CardScheme`](http://symfony.com/doc/current/reference/constraints/CardScheme.html)
- [`Currency`](http://symfony.com/doc/current/reference/constraints/Currency.html)
- [`Luhn`](http://symfony.com/doc/current/reference/constraints/Luhn.html)
- [`Iban`](http://symfony.com/doc/current/reference/constraints/Iban.html)
- [`Isbn`](http://symfony.com/doc/current/reference/constraints/Isbn.html)
- [`Issn`](http://symfony.com/doc/current/reference/constraints/Issn.html)

### Example

[](#example)

...

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8058106?v=4)[Mario Alicicco](/maintainers/nebumix)[@Nebumix](https://github.com/Nebumix)

---

Top Contributors

[![Nebumix](https://avatars.githubusercontent.com/u/8058106?v=4)](https://github.com/Nebumix "Nebumix (57 commits)")

### Embed Badge

![Health badge](/badges/nebumix-rt-validation-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/nebumix-rt-validation-bundle/health.svg)](https://phpackages.com/packages/nebumix-rt-validation-bundle)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
