2017 © Pedro Peláez
 

library one-validator

Convert server-side to client-side validation

image

fish/one-validator

Convert server-side to client-side validation

  • Saturday, October 11, 2014
  • by matfish2
  • Repository
  • 1 Watchers
  • 2 Stars
  • 22 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Server->Client Validation Converter

While client-side validation is a standard nowadays, setting it is tedious and anti-DRYful. This Laravel 4+ package will convert your server-side rules to the popular JQuery validate plugin format, while adding all of the necessary assets to support the Laravel set of rules (including remote rules) and messages (including custom attributes and localization). File and date rules are not supported and will be ignored., (*2)

Installation

Begin by installing this package through Composer. Edit your project's composer.json file to require fish/one-validator., (*3)

"require-dev": {
    "fish/one-validator": "dev-master"
}

Next, update Composer from the Terminal:, (*4)

composer update

Once this operation completes, the final step is to add the service provider. Open app/config/app.php, and add a new item to the providers array., (*5)

Fish\OneValidator\OneValidatorServiceProvider

Next, publish the assets to your project:, (*6)

php artisan validator:init

The file that handles the validation methods and messages will be placed under public/one-validator.min.js. Be sure to include the script in your page., (*7)

That's it! You're all set to go., (*8)

Usage

The syntax is:, (*9)

php artisan validator:convert path/to/file [--target=validation.js]

The first argument is the path to a PHP file with a valid $rules array, relative to the app folder., (*10)

By default the output will be echoed to the console. You can send the output to a file instead by using the target option, providing a path relative to the app folder., (*11)

Remember to replace the default .my-form selector with your own form selector., (*12)

The Versions