PHPackages                             onemoreblock/laravel-validatorjs - 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. onemoreblock/laravel-validatorjs

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

onemoreblock/laravel-validatorjs
================================

Frontend form validation library with validatorjs API for Laravel

00PHP

Since Oct 17Pushed 4y agoCompare

[ Source](https://github.com/OneMoreBlock/laravel-validatorjs)[ Packagist](https://packagist.org/packages/onemoreblock/laravel-validatorjs)[ RSS](/packages/onemoreblock-laravel-validatorjs/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Validatorjs API for Laravel 7+
==============================

[](#validatorjs-api-for-laravel-7)

### This package is created to handle the frontend form validation by just writing one set of rules for both Laravel and apply them for frontend also

[](#this-package-is-created-to-handle-the-frontend-form-validation-by-just-writing-one-set-of-rules-for-both-laravel-and-apply-them-for-frontend-also)

**This library generates the frontend validation rules for a form and displaying the errors for respected input/options all of this is done by just defining your Laravel Form Requests, and it also supports laravel's custom attributes names and error message customization**

### \*\* This library is far from being perfect and currently dosen't suit all the use cases, but still it will work ifor most requirements \*\*

[](#-this-library-is-far-from-being-perfect-and-currently-dosent-suit-all-the-use-cases-but-still-it-will-work-ifor-most-requirements-)

TODO
----

[](#todo)

- Generate the validation rules which are **supported** by both **Laravel** and **Validatorjs**
- Add **support** for\*\* Tailwind CSS\*\* errors (Currently only supports auto error display for **Bootstrap 5**)
- Add Support for adding **custom validation rules**

Quick Installation
------------------

[](#quick-installation)

```
$ composer require onemoreblock/laravel-validatorjs
```

Requirements
------------

[](#requirements)

- [PHP &gt;= 7.0](http://php.net/)
- [Laravel 7|8](https://github.com/laravel/framework)

#### Configuration

[](#configuration)

```
$ php artisan vendor:publish --provider="OneMoreBlock\Validatorjs\ValidatorJsServiceProvider"
```

### Usage

[](#usage)

Currently this package only supports validator js rules generation by using only laravel form requests. So start by creating a laravel Form Request eg: PostRequest

```
$ php artisan make:request PostRequest
```

Now open the generated PostRequest file and add make sure to do trhe following

- Replace the default extends class from **FormRequest** with **Validatorjs**
- Add a **protected** variable \*\*$tableID \*\* ( ID of the table for which to apply the validation on)
- Add a **protected** variable \*\*$successCallback \*\* (function name that is to be called on successful validation)
- Now define you validation rules just like before 😃 Here is the sample example for PostRequest

```
