I read through all the replies, and there's one pattern of data valdation I've always liked: rule based. You'd create an engine that you plugged in some sort of configuration space. Each rule would have a method to determine if the input passed is valid or not. If it is, a positive effect occurs. True is returned, an exception is not thrown.. something. On failure, false or an exception is created.
For perl, I would imagine a system where everything must implement a base Rule object. The engine would create one of each rule and have some sort of "validate" function. Next, wrap whatever framework away from the developer. Your Wrapped framework would have a method for getting data, "get_validated_data" which would take a pointer to your validator configuration as to which object to use. I would then be able to do something ala...
my $frameWork = WrapedFrameWork->new();
my $allValid = 1;
my ( $valid, $data ) = $frameWork->get_validated_data("email","typeEma
+il");
$allValid &= $valid;
if( !$allValid )
{
....
}
If your developers do code reviews, which they should, any bypassing the system can be slapped down. New validators can be written for everyone to use. Life may be cleaner.. in an ideal world 8)
----
Give me strength for today..
I will not talk it away..
Just for a moment..
It will burn through the clouds..
and shine down on me.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.