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

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

filpgame/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.1.2(10y ago)02251MITPHPPHP &gt;=5.3.0

Since Mar 16Pushed 10y ago1 watchersCompare

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

READMEChangelogDependencies (4)Versions (13)Used By (0)

\#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)
- [Changelog](#changelog)
- [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.1.*", //or "5.0.*"
        ...
        "bllim/laravalid": "*"
    }
    ...
}

```

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

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',
    ),
```

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

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/laravalid folder. 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 not supported yet.

**Validation Messages**

Converter uses validation messages of laravel (app/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 {

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

    public function getCreate()
    {
        Form::setValidation($this->createValidation);
        return View::make('user.create');
    }

    public function postCreate()
    {
        $inputs = Input::only($this->createColumns);
        $rules = $this->createValidation;

        $validator = Validator::make($inputs, $rules);

        if($validator->fails())
        {
            // actually withErrors is not really neccessary 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 baseconverter 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 `converters` 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.validation.laravel.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.

**Convertion Logic**Package converts rules by using converters (in src/converters). It uses Converter class of chosen plugin which extends BaseConverter/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)

- Test script
- Support unsupported rules
- Improve doc
- Comment code

### Changelog

[](#changelog)

**v1.0**

- Initial commit

### License

[](#license)

Licensed under the MIT License

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 56.3% 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.

###  Release Activity

Cadence

Every ~28 days

Recently: every ~62 days

Total

11

Last Release

3792d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/84cd24f5d4305f0fea451835b41a11722817b460f33b746ab555c1371882feec?d=identicon)[filpgame](/maintainers/filpgame)

---

Top Contributors

[![bllim](https://avatars.githubusercontent.com/u/44695920?v=4)](https://github.com/bllim "bllim (9 commits)")[![filpgame](https://avatars.githubusercontent.com/u/5223937?v=4)](https://github.com/filpgame "filpgame (5 commits)")[![igorsantos07](https://avatars.githubusercontent.com/u/532299?v=4)](https://github.com/igorsantos07 "igorsantos07 (2 commits)")

---

Tags

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

### Embed Badge

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

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

###  Alternatives

[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.

5915.2k](/packages/bllim-laravalid)[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)[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)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)

PHPackages © 2026

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