1Workflow::Validator::HaUssReerquCiornetdrFiibeultde(d3W)PoerrklflDoowc:u:mVeanltiadtaitoonr::HasRequiredField(3)
2
3
4
6 Workflow::Validator::HasRequiredField - Validator to ensure certain
7 data are in the context
8
10 # Validator is created automatically when you mark a field as
11 # 'is_required=yes' in the action, such as:
12
13 <action name="CreateUser">
14 <field name="username"
15 is_required="yes"
16 source_class="App::Fied::ValidUsers"/>
17 ...
18
20 This is a simple validator to ensure that each of the fields you have
21 marked with the 'is_required' property as 'yes' are indeed present
22 before the associated action is executed.
23
24 for instance, given the configuration:
25
26 <action name="CreateUser">
27 <field name="username"
28 is_required="yes"/>
29 <field name="email"
30 is_required="yes"/>
31 <field name="office">
32 </action>
33
34 An action executed with such a context:
35
36 my $wf = FACTORY->get_workflow( $id );
37 $wf->context( username => 'foo' );
38 $wf->context( office => 'Ottumwa' );
39 $wf->execute_action( 'CreateUser' );
40
41 Would fail with a message:
42
43 The following fields require a value: email
44
45 You normally do not need to configure this validator yourself. It gets
46 generated automatically when the Action configration is read in. How‐
47 ever, if you do need to create it yourself:
48
49 <action name='Foo'>
50 <validator name="HasRequiredField">
51 <arg value="fieldOne"/>
52 <arg value="field_two"/>
53 </validator>
54 <?action>
55
56 Note that we do not try to match the value in the context against a set
57 of known values or algorithm, just see if the value is defined -- using
58 the Perl notion for defined rather than true/false, which means '0' and
59 the empty string will both be valid.
60
61 METHODS
62
63 #=head3 validate
64
66 Copyright (c) 2003-2004 Chris Winters. All rights reserved.
67
68 This library is free software; you can redistribute it and/or modify it
69 under the same terms as Perl itself.
70
72 Chris Winters <chris@cwinters.com>
73
74
75
76perl v5.8.8 2007-W0o4r-k2f5low::Validator::HasRequiredField(3)