brian d foy > Brick-0.226_02 > Brick::UserGuide

Download:
Brick-0.226_02.tar.gz

Annotate this POD

Source  

NAME ^

Brick::UserGuide - How to use Brick

SYNOPSIS ^

DESCRIPTION ^

Some one told you to use this module to validate data, and you need to know the shortest way to get that done. Someone else has created all the validation routines, or "bricks", already and you just have to use them.

Construct your profile

Your validation description is the business rules that you want to apply to your input. It's just a list of anonymous arrays that tell Brick what to do (see Brick::Profile):

        @Description = (
                [ label => constraint_name => { setup hash } ],
                ...
                );
        
        my $Brick = Brick->new();
        
        my $profile = $Brick->profile_class->new( \@Description );

When you apply this profile, Brick does it's magic.

        my $result = $Brick->apply( $profile, \%Input );

Brick goes through the profile one anonymous array at a time, and in order. It validates one row of the anonymous array, saves the result, and moves on to the next anonymous array. At the end, you have the results in $result, which is a Brick::Results object.

That anonymous array's elements correspond item for item to the elements in the profile. The first element in $result goes with the first element in @Profile.

Each element in $result is an anonymous array holding four items:

The label of the profile element
The constraint it ran
The result: True if the data passed, and false otherwise.
The error message, if any, as an anonymous hash.

Getting the error messages

        XXX: In progress

SOURCE AVAILABILITY ^

This source is part of a SourceForge project which always has the latest sources in SVN, as well as all of the previous releases.

        svn co https://brian-d-foy.svn.sourceforge.net/svnroot/brian-d-foy brian-d-foy

If, for some reason, I disappear from the world, one of the other members of the project can shepherd this module appropriately.

AUTHOR ^

brian d foy, <bdfoy@cpan.org>

COPYRIGHT ^

Copyright (c) 2007, brian d foy, All Rights Reserved.

You may redistribute this under the same terms as Perl itself.

syntax highlighting: