Announcing the first (announced) public release of ValidForm, available
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
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
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.
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
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
(-, /\ / / //