PHPackages                             bllim/laravalid - 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. bllim/laravalid

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

bllim/laravalid
===============

This package makes validation rules defined in laravel work client-side by converting to html/js plugins such as jquery validation. It also allows to use laravel validation messages so you can show same messages for both sides.

v1.3.3(8y ago)5915.2k29[1 issues](https://github.com/bgultekin/laravalid/issues)MITPHPPHP &gt;=5.4.0

Since Mar 16Pushed 8y ago7 watchersCompare

[ Source](https://github.com/bgultekin/laravalid)[ Packagist](https://packagist.org/packages/bllim/laravalid)[ RSS](/packages/bllim-laravalid/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (21)Used By (0)

Laravalid [![Build Status](https://camo.githubusercontent.com/5e17ed701a35c268008456ec59fbeccb0d37d90a807911a7606734548d699cf4/68747470733a2f2f7472617669732d63692e6f72672f6267756c74656b696e2f6c61726176616c69642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/bgultekin/laravalid)
==================================================================================================================================================================================================================================================================================================

[](#laravalid-)

#### Laravel Validation For Client Side

[](#laravel-validation-for-client-side)

This package makes validation rules defined in laravel work client-side by converting to html/js plugins such as jquery validation. It also allows to use laravel validation messages so you can show same messages for both sides.

### Table of contents

[](#table-of-contents)

- [Feature Overview](#feature-overview)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Extending](#extending)
- [Plugins and Supported Rules](#plugins-and-supported-rules)
- [Known Issues](#knownissues)
- [To Do](#todo)
- [Contributors](#contributors)
- [Licence](#licence)

### Feature Overview

[](#feature-overview)

- Multi-Plugin Support *//For now, there is just one :)*
    - `Jquery Validation`
- Extendible
- Laravel form builder based
- Validation rules can be set from controller
- Distinguishing between numeric input and string input
- User friendly input names
- Remote rules such as unique and exists

### Installation

[](#installation)

Require `bllim/laravalid` in composer.json and run `composer update`.

```
    {
        "require": {
            "laravel/framework": "5.2.*", //or "5.0.*"
            ...
            "bllim/laravalid": "*"
        }
        ...
    }
```

> **Note:** For **Laravel 4** use `laravel4` branch like as `"bllim/laravalid": "dev-laravel4"` or `"~0.9"`

Composer will download the package. After the package is downloaded, open `config/app.php` and add the service provider and alias as below:

```
    'providers' => array(
        ...
            Bllim\Laravalid\LaravalidServiceProvider::class,
    ),
```

```
    'aliases' => array(
        ...
            'HTML'      => Collective\Html\HtmlFacade::class, // if not exists add for html too
            'Form'      => Bllim\Laravalid\Facade::class,
    ),
```

Also you need to publish configuration file and assets by running the following Artisan commands.

```
$ php artisan vendor:publish
```

### Configuration

[](#configuration)

After publishing configuration file, you can find it in `config` folder as `laravalid.php` file. Configuration parameters are as below:

ParameterDescriptionValuespluginChoose plugin you want to useSee [Plugins and Supported Rules](#plugins-and-supported-rules)useLaravelMessagesIf it is true, laravel validation messages are used in client side otherwise messages of chosen plugin are usedtrue/falserouteRoute name for remote validationAny route name (default: laravalid)### Usage

[](#usage)

The package uses laravel Form Builder to make validation rules work for both sides. Therefore you should use Form Builder. While opening form by using `Form::open` you can give `$rules` as second parameter:

```
    $rules = ['name' => 'required|max:100', 'email' => 'required|email', 'birthdate' => 'date'];
    Form::open(array('url' => 'foo/bar', 'method' => 'put'), $rules);
    Form::text('name');
    Form::text('email');
    Form::text('birthdate');
    Form::close(); // don't forget to close form, it reset validation rules
```

Also if you don't want to struggle with `$rules` at view files, you can set it in `Controller` or route with or without form name by using `Form::setValidation($rules, $formName)`. If you don't give form name, this sets rules for first `Form::open`

```
    // in controller or route
    $rules = ['name' => 'required|max:100', 'email' => 'required|email', 'birthdate' => 'date'];
    Form::setValidation($rules, 'firstForm'); // you can also use without giving form name Form::setValidation($rules) because there is just one.

    // in view
    Form::open(array('url' => 'foo/bar', 'method' => 'put', 'name' => 'firstForm'), $rules);
    // some form inputs
    Form::close();
```

For rules which is related to input type in laravel (such as `max`, `min`), the package looks for other given rules to understand which type is input. If you give integer or numeric as rule with `max`, `min` rules, the package assume input is numeric and convert to `data-rule-max` instead of `data-rule-maxlength`.

```
    $rules = ['age' => 'numeric|max'];
```

The converter assume input is `string` by default. File type is also supported.

**Validation Messages**

Converter uses validation messages of laravel (`resources/lang/en/validation.php`) by default for client-side too. If you want to use jquery validation messages, you can set `useLaravelMessages`, false in config file of package which you copied to your config dir.

#### Plugins

[](#plugins)

**Jquery Validation**While using Jquery Validation as html/js validation plugin, you should include `jquery.validate.laravalid.js` in your views, too. After assets published, it will be copied to your public folder. The last thing you should do at client side is initializing jquery validation plugin as below:

```

$('form').validate({onkeyup: false}); //while using remote validation, remember to set onkeyup false

```

#### Example

[](#example)

Controller/Route side

```
class UserController extends Controller {

    static $createValidations = ['name' => 'required|max:255', 'username' => 'required|regex:/^[a-z\-]*$/|max:20', 'email' => 'required|email', 'age' => 'numeric'];

    public function getCreate()
    {
        Form::setValidation(static::$createValidations);
        return View::make('user.create');
    }

    public function postCreate()
    {
        $inputs = Input::only(array_keys(static::$createValidations));
        $validator = Validator::make($inputs, static::$createValidations);

        if ($validator->fails())
        {
            // actually withErrors is not really necessary because we already show errors at client side for normal users
            return Redirect::back()->withErrors($validator);
        }

        // try to create user

        return Redirect::back()->with('success', 'User is created successfully');
    }
}
```

View side

```
>

      Laravalid

        {{ Form::open('url'=>'create', 'method'=>'post') }}
        {{ Form::text('name') }}
        {{ Form::text('username') }}
        {{ Form::email('email') }}
        {{ Form::number('age') }}
        {{ Form::close() }}

        $('form').validate({onkeyup: false});

```

### Extending

[](#extending)

There are two ways to extend package with your own rules. First, you can extend current converter plugin dynamically like below:

```
Form::converter()->rule()->extend('someotherrule', function($parsedRule, $attribute, $type){
    // some code
    return ['data-rule-someotherrule' => 'blablabla'];
});
Form::converter()->message()->extend('someotherrule', function($parsedRule, $attribute, $type){
    // some code
    return ['data-message-someotherrule' => 'Some other message'];
});
Form::converter()->route()->extend('someotherrule', function($name, $parameters){
    // some code
    return ['valid' => false, 'messages' => 'Seriously dude, what kind of input is this?'];
});
```

Second, you can create your own converter (which extends `Base\Converter` or any current plugin converter) in `Bllim\Laravalid\Converter\` namespace and change plugin configuration in config file with your own plugin name.

> **Note:** If you are creating a converter for some existed html/js plugin please create it in `Converter` folder and send a pull-request.

### Plugins and Supported Rules

[](#plugins-and-supported-rules)

**Jquery Validation**To use Jquery Validation, change plugin to `JqueryValidation` in config file and import `jquery`, `jquery-validation` and **jquery.validate.laravalid.js** in views.

RulesJquery ValidationAccepted-Active URL`+`After (Date)`+`Alpha`+`Alpha Dash-Alpha Numeric`+`Array-Before (Date)`+`Between`+`Boolean-Confirmed-Date`+`Date Format-Different`+`Digits-Digits Between-E-Mail`+`Exists (Database)`+`Image (File)`+`In-Integer`+`IP Address`+`Max`+`MIME Types`+`Min`+`Not In-Numeric`+`Regular Expression`+`Required`+`Required If-Required With`+`Required With All-Required Without`+`Required Without All-Same`+`Size-String-Timezone-Unique (Database)`+`URL`+`> **Note:** It is easy to add some rules. Please check `Rule` class of related converter.

### Contribution

[](#contribution)

You can fork and contribute to development of the package. All pull requests is welcome.

**Conversion Logic**Package converts rules by using converters (in `src/Bllim/Laravalid/Converter`). It uses `Converter` class of chosen plugin which extends `Converter/Base/Converter` class. You can look at existed methods and plugins to understand how it works. Explanation will be ready, soon.

### Known issues

[](#known-issues)

- Some rules are not supported for now

### TODO

[](#todo)

- Support unsupported rules
- Improve doc
- Comment code

### Contributors

[](#contributors)

- @bllim
- @phpspider
- @jannispl
- @rene-springmann
- @nthachus

and [more](https://github.com/bllim/laravalid/graphs/contributors)

### License

[](#license)

Licensed under the MIT License

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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.

###  Release Activity

Cadence

Every ~59 days

Recently: every ~0 days

Total

19

Last Release

3005d ago

Major Versions

v0.9.1 → v1.3.12018-02-24

v0.9.2 → v1.3.32018-02-24

PHP version history (2 changes)v1.0.0PHP &gt;=5.3.0

v1.3.1PHP &gt;=5.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c051715d4855bb822e424c43e178349bcc018693a9c025da4042e1c37bed1758?d=identicon)[bgultekin](/maintainers/bgultekin)

---

Top Contributors

[![bllim](https://avatars.githubusercontent.com/u/44695920?v=4)](https://github.com/bllim "bllim (14 commits)")[![nthachus](https://avatars.githubusercontent.com/u/4475386?v=4)](https://github.com/nthachus "nthachus (13 commits)")[![rene-vorndran](https://avatars.githubusercontent.com/u/1486227?v=4)](https://github.com/rene-vorndran "rene-vorndran (11 commits)")[![bgultekin](https://avatars.githubusercontent.com/u/1005480?v=4)](https://github.com/bgultekin "bgultekin (3 commits)")[![igorsantos07](https://avatars.githubusercontent.com/u/532299?v=4)](https://github.com/igorsantos07 "igorsantos07 (2 commits)")[![yapsr](https://avatars.githubusercontent.com/u/3018553?v=4)](https://github.com/yapsr "yapsr (1 commits)")

---

Tags

laravelvalidationlaravel5client-sidelaravel-validationjquery validationlaravel validation converterlaravel validation for client-sidebootstrap validation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bllim-laravalid/health.svg)

```
[![Health](https://phpackages.com/badges/bllim-laravalid/health.svg)](https://phpackages.com/packages/bllim-laravalid)
```

###  Alternatives

[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

759569.4k13](/packages/wendelladriel-laravel-validated-dto)[galahad/laravel-addressing

Laravel package providing addressing functionality

70316.6k](/packages/galahad-laravel-addressing)

PHPackages © 2026

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