-
Notifications
You must be signed in to change notification settings - Fork 17
Home
Work-in-progress documentation. Feel free to edit at will.
In an ideal world, this plugin works out of the box. There are a few things to be aware of, though. Here you go:
The plugin does not provide any live validation javascripts by itself, it uses existing live validation javascript libraries. Here’s installation/configuration documentation specific to each of the adapters:
-
2.2 or older:
ruby script/generate live_validator
- 2.3 or newer: Nothing.
The database is the only place we can ask about record uniqueness. In order to make the javascripts able to ask the database, we need some controller callbacks. In 2.3 and beyond, plugins can add controllers. Before 2.3 they can’t, so you need to generate the controller into your app/controllers, as mentioned above.
Note this is only implemented for jQuery, not for livevalidation.com.
The regexp provided in your model will be displayed as-is to the javascripts. The plugin does not do anything to try to cope with differences between Ruby and JS regular expressions, so you can specify a JS specific regexp with the :live_validator
option. A semi-sensible example:
validates_format_of :foo, :with => /\A[a-z]\z/, :live_validator => /^[a-z]$/
The plugin will ask the I18n library for validation messages. If you specify :message
in your validation, this message will be used. Interpolating {model}
is supported (such as :message => "is not as {model} as you might think"
). Other I18n interpolations such as {{value}}
and {{attribute}}
is not supported.
- validates_numericality_of does not support most of the options like :greater_than, etc.
- validates_uniqueness_of is not supported with livevalidations.com validators
- Options :if and :unless are ignored; validations will always apply