[Dbix-class] Proposed: DBIx::Class::Validator

Aran Deltac aran at arandeltac.com
Wed Dec 14 00:31:58 CET 2005


Hey all.  I've put together a module that wraps in FormValidator::Simple. 
mst says it would be a good addition to Core, so I'm posting the
textualized pod here for anyone to suggest changes or make comments,
before I make any commits.  The code can be viewed, temporarly, in my SVN
repo:

http://svn.silentforest.net/dbix-class-validator/

Aran

-------------------------

NAME
    DBIx::Class::Validator - Validate all data before submitting to your
    database.

SYNOPSIS
    In your base DBIC package:

      __PACKAGE__->load_components(qw/... Validator/);

    And in your subclasses:

      __PACKAGE__->validator_profile(
        # FormValidator::Simple profile.
      );

    And then somewhere else:

      eval{ $obj->validate() };
      if( my $results = $EVAL_ERROR ){
        # See Data::FormValidator::Results for examples.
      }

METHODS
  validator_profile
      __PACKAGE__->validator_profile(
        # FormValidator::Simple profile.
      );

    Sets the FormValidator::Simple profile for this class. The profile is
    inheritable, so any subclasses will inherit this profile, or may choose
    to overright it.

  validate
      $obj->validate();

    Validates all the data in the object against the pre-defined validator
    profile. If there is an problem then a hard error will be thrown. If you
    put the validation in an eval you can capture the result object and find
    out what was invalid.

  auto_validate
      __PACKAGE__->auto_validate( 0 );

    Turns on and off auto-validation. This feature makes all UPDATEs and
    INSERTs call the validate() method before doing anything. The default is
    for auto-validation to be on.

AUTHOR
    Aran C. Deltac <bluefeet at cpan.org>

LICENSE
    You may distribute this code under the same terms as Perl itself.







More information about the Dbix-class mailing list