What's more, the HTML template system allows the designer to position and style the error message. Also, the custom error messages can be kept in seperate file for easy editing (I use Config::General for loading and reading the file). My error config file looks like this:
<msgs> any_errors = err__ prefix = err_ <constraints> OK_dn_unique = Domain name already used within Citigroup OK_dn = Badly formed domain name OK_words = Illegal character in string OK_chars = Illegal character or space in string OK_sql = Illegal SQL character in string OK_phone_chars = Illegal phone character(s) or format OK_int = Illegal integer OK_date = Illegal date character(s) or format OK_email = Illegal email format </constraints> </msgs>
The key of the constraints hash in the function name of the constraint. Details are explained clearly in the validateRM docs. Here's an example validate/untaint function I wrote (note how simple it is):
I highly recommend using these modules.sub match_OK_phone_chars { my $val = shift; if ( $val =~ /^([-\d. \(\)]{10,}[extEX .-\d]*)$/ ) { return $1; } else { return undef; } }
-------------------------------------
Nothing is too wonderful to be true
-- Michael Faraday
In reply to Re: Form validation: preferred modules?
by freddo411
in thread Form validation: preferred modules?
by Hagbone
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |