Brick/UserGuide.pm untested

filter: Statementstmt n/a Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a SCAR -
1 package Brick::UserGuide;
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 Brick::UserGuide - How to use Brick
8  
9 =head1 SYNOPSIS
10  
11 =head1 DESCRIPTION
12  
13 Some one told you to use this module to validate data, and you need to
14 know the shortest way to get that done. Someone else has created all
15 the validation routines, or "bricks", already and you just have to use
16 them.
17  
18 =head2 Construct your profile
19  
20 Your validation description is the business rules that you want to
21 apply to your input. It's just a list of anonymous arrays that tell
22 Brick what to do (see L<Brick::Profile>):
23  
24 @Description = (
25 [ label => constraint_name => { setup hash } ],
26 ...
27 );
28  
29 my $Brick = Brick->new();
30  
31 my $profile = $Brick->profile_class->new( \@Description );
32  
33 When you C<apply> this profile, Brick does it's magic.
34  
35 my $result = $Brick->apply( $profile, \%Input );
36  
37 Brick goes through the profile one anonymous array at a time, and in order.
38 It validates one row of the anonymous array, saves the result, and moves on
39 to the next anonymous array. At the end, you have the results in C<$result>,
40 which is a C<Brick::Results> object.
41  
42 That anonymous array's elements correspond item for item to the elements in
43 the profile. The first element in C<$result> goes with the first element
44 in C<@Profile>.
45  
46 Each element in C<$result> is an anonymous array holding four items:
47  
48 =over 4
49  
50 =item The label of the profile element
51  
52 =item The constraint it ran
53  
54 =item The result: True if the data passed, and false otherwise.
55  
56 =item The error message, if any, as an anonymous hash.
57  
58 =back
59  
60 =head2 Getting the error messages
61  
62 XXX: In progress
63  
64 =head1 SOURCE AVAILABILITY
65  
66 This source is in Github:
67  
68 https://github.com/briandfoy/brick
69  
70 =head1 AUTHOR
71  
72 brian d foy, C<< <briandfoy@pobox.com> >>
73  
74 =head1 COPYRIGHT
75  
76 Copyright © 2007-2025, brian d foy <briandfoy@pobox.com>. All rights reserved.
77  
78 You may redistribute this under the terms of the Artistic License 2.0.
79  
80 =cut
81  
82 1;