[ANN] ValidForm 1.0

G

Gavin Kistner

Announcing the first (announced) public release of ValidForm, available
at http://phrogz.net/RubyLibs/


HELP ME HELP YOU
================
Before reading what ValidForm is (below) please read this: other than
the (relatively trivial) MutableTime library, this is my first real Ruby
code. Please, please: if you are a Ruby guru, take 3 minutes to scan
through the code. Are there any obvious newbie mistakes? Ways things
could be done more cleanly? Ways things could be done in a more Ruby
fashion?

A lot of criticism is desired. No, really :)


WHAT IS IT?
===========
From the documentation on the ValidForm.rb file:

The ValidForm library allows you to specify a form fully in Ruby code,
along with validation rules for that data. You can then easily emit an
HTML version of that form (either fully--with a single method call--or
in controlled pieces) which includes the hooks needed for client-side
validation using FormAutoValidate
(http://phrogz.net/tmp/FormAutoValidate/formautovalidate_docs.html).

Because client-side isn't enough, you can then re-validate the data
server-side in Ruby (again with a single method call to pull the
submitted values into the form and validate them).

Finally, re-emitting the html for an already-validated form emits CSS
hooks and validation error messages.

ValidFormTest.tar.gz (http://phrogz.net/RubyLibs/ValidFormTest.tar.gz)
is a fully-functioning mod_ruby/eRuby example, with files showing how to:

* Create a complex form, with various validation rules.

* Emit the HTML for that form.

* Use CSS to style the semantic markup in non-trivial ways. (At least
for Safari/Mozilla...I have no idea if IEWin supports this particular
example properly.)

* View the client-side library in action.

* Load the values back into the form server-side, re-validate, and
re-emit new HTML noting the errors.


One caveat: the hooks needed for FormAutoValidate produce ‘invalid’
HTML; that is, the output will no longer validate as HTML4 because of
the custom attributes put into the fields. This should cause no problems
for the browser, as in all other ways the output should be HTML4Strict
compliant.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,281
Latest member
Pedroaciny

Latest Threads

Top