I have code in progress that provides a framework for application-
specific data validation routines.

Example:

  my $val = new Validator();

  my $credit_card = {
                     "number" => "4321432143214327",
                     "expiration" => "07/03",
                     "cardholder" => {
                                      "name" => "Jane Smith",
                                      "address" => "123 Main St.",
                                      "city" => "New York",
                                      "state" => "NY",
                                      "zip" => "10001"
                                     }
                    };

  $val->validate_card($credit_card) or die "Bad card!";


Rules are implemented in the form of code fragments that can
be stored in files or a database - outside the main body of
the application.  Rules are loaded when invoked, and can be
altered on the fly without restarting the program.  This is
specifically intended for use in persistent applications such
as web services.  The code makes use of AUTOLOAD - e.g. the
'validate_card' function above is never explicitly defined,
but is read in from an external rule at runtime.

The validator builds up a list of rules that were processed,
so the application can then check for failed rules and generate
an appropriate error message to the user (e.g. "Card number has
insufficient digits", "Expiration date is a required field").

Seeking the wisdom of the list:

  * Is this likely to be useful to anyone else besides me?

  * Am I re-inventing the wheel?  I've scanned the other
    validation-related modules on CPAN (CGI::Validate,
    Data::FormValidator, Params::Validate and others) and
    none are quite what I need.

  * What should I call this thing?  Data::Validator?
    Data::AutoValidator?  It works with CGI, Apache
    and so on but it's independent from those.
    Any suggestions?

Thanks,
-Jason

Reply via email to