[dancer-users] Form validation framework

Warren Young warren at etr-usa.com
Mon Apr 14 19:58:30 BST 2014

On 4/14/2014 09:58, Octavian Rasnita wrote:
> From: "Lutz Gehlen" <lrg_ml at gmx.net>
>> is there a generally recommended form validation framework for Dancer?
>> There are several plugins on CPAN, but they all seem to be rather
>> basic (at
>> least on first glance). A key feature for me is that error messages
>> can be
>> easily displayed together with the respective input fields and not
>> only as a
>> group of error messages.

It sounds like you want client-side validation, which doesn't involve 
Dancer at all.

Since Dancer ships assuming you're going to use jQuery, how about trying 
the first result I got when Googling jQuery validation:


Let me know how it works if you do try it.  I might be interested in 
adopting it myself.  (All my current client-side validation code is 

You should also do server-side validation, but I wouldn't try to tie 
errors at that level back to specific UI fields.  For an error to get 
past client-side validation but be caught by server-side validation, 
there are only two possibilities:

1. Your client and server-side validation rules have gotten out of sync. 
  I don't know a Dancer-friendly way to keep them in sync.  It probably 
wouldn't be trivial, since the languages and frameworks on each side are 
different.  The only system I've ever used that did let you keep them in 
sync had the feature only because it was a server-side JavaScript 
application server, so literally the same code could run on both sides. 
  (Not node.js, but vaguely similar concept.)

2. Someone is submitting form data directly, bypassing the UI.  A hacker 
doing that isn't going to care that you've nicely bound the complaints 
to specific UI elements.

More information about the dancer-users mailing list