live_validator

github.com/midas/live_validator/tree/master

DESCRIPTION:

Live validator is a Rails Guilded (github.com/midas/guilded/tree/master) component that will reflect ActiveRecord validations and use them to live validate forms. Live validator uses the Live Validation (www.livevalidation.com) JavaScript library to accomplish this task. It also uses an ActiveRecord extension authored by Michael Schuerig to mre easily reflect on the ActiveRecord valdiations.

FEATURES:

  • Validate Rails XHTML forms without submitting form to server.

  • Declare validations once in ActiveRecord model’s. If JavaScript is enabled, the validation will happen live. Otherwise, the validation will happen normally, with a submission to the server.

  • The error message defined in the validation macro will be used in live validation

  • The following ActiveRecrod validations are currently implemented and working: validates_presence_of (:message), validates_numericality_of (:less_than, :less_than_or_equal_to, :equal_to, :greater_than, :greater_then_or_equal_to, :only_integer, :notANumberMessage, :notAnIntegerMessage, :wrongNumberMessage, :tooLowMessage, :tooHighMessage), validates_length_of / validates_size_of (:maximum, :minimum, :is, :within, :in, :too_long, :too_short, :wrong_length), validates_confirmation_of (Only works for 2 fields, no more nor less.), validates_acceptance_of (:message), validates_inclusion_of (:message), validates_exclusion_of (:message)

PROBLEMS:

INSTALL:

sudo gem install midas-g_live_validator

Add gem requirement to your environment.rb file:

config.gem 'midas-g_live_validator', :version => '1.0.4', :lib => 'g_live_validator', :source => 'http://gems.github.com'

Generate:

script/generate live_validator_assets

USE:

Make a call to the view_helper within a form:

<%= g_live_validator f %> # where f is the form variable passed into the form_for block

OPTIONS:

:except - List of fields not to validate. Foreign key fields (that end in _id) are automatically excluded. Can be a string, symbol or an array of string or sybmols.

REQUIREMENTS:

LICENSE:

(The MIT License)

Copyright © 2009 midas (excluding included material copyrighted by others)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.