green_light icon indicating copy to clipboard operation
green_light copied to clipboard

Simple client side validation for Rails that keeps validation in the models

= green_light {Build Status}[https://travis-ci.org/overture8/green_light]

Provides client side validation, with the help of the {jquery validation plugin}[http://bassistance.de/jquery-plugins/jquery-plugin-validation/]. Keeping validation in the model, where it belongs.

== Installation

Add green_light to your Gemfile and run the bundle install command.

gem 'green_light'

== Usage

Include the JQuery validation plugin in your app/assets/javascripts/application.js file:-

//= require jquery.validate

Since the validation rules are creating dynmically they need to be included in the header of your layout file:-

<%= javascript_include_tag "green_light" %>

Add the green_light class to the forms that you wish to have client side validation:-

<%= form_for(@model, :html => { :class => 'green_light' }) do |f| %>

And finally, add some validations to your models!

== Currently Supports these validations

validates_presence_of validates_length_of validates_format_of validates_uniqueness_of validates_numericality_of

For validations that are not yet supported, the gem will degrade gracefully to the standard Rails server-side validation.

== Legacy Rails 3 Support

For Rails 3 support use the older version (0.0.3) of green_light

== Requirements

JQuery is require for the {jquery validation plugin}[http://bassistance.de/jquery-plugins/jquery-plugin-validation/]. Be sure to include this in your application.js file:-

//= require jquery

== Running the Tests

bundle install bundle exec rspec spec