1Data::FormValidator(3)User Contributed Perl DocumentationData::FormValidator(3)
2
3
4

NAME

6       Data::FormValidator - Validates user input (usually from an HTML form)
7       based on input profile.
8

SYNOPSIS

10        use Data::FormValidator;
11
12        my $results = Data::FormValidator->check(\%input_hash, \%dfv_profile);
13
14        if ($results->has_invalid or $results->has_missing) {
15            # do something with $results->invalid, $results->missing
16            # or  $results->msgs
17        }
18        else {
19            # do something with $results->valid
20        }
21

DESCRIPTION

23       Data::FormValidator's main aim is to make input validation expressible
24       in a simple format.
25
26       Data::FormValidator lets you define profiles which declare the required
27       and optional fields and any constraints they might have.
28
29       The results are provided as an object which makes it easy to handle
30       missing and invalid results, return error messages about which
31       constraints failed, or process the resulting valid data.
32

VALIDATING INPUT

34   check()
35        my $results = Data::FormValidator->check(\%input_hash, \%dfv_profile);
36
37       "check" is the recommended method to use to validate forms. It returns
38       its results as a Data::FormValidator::Results object.  A deprecated
39       method "validate" is also available, returning its results as an array
40       described below.
41
42        use Data::FormValidator;
43        my $results = Data::FormValidator->check(\%input_hash, \%dfv_profile);
44
45       Here, "check()" is used as a class method, and takes two required
46       parameters.
47
48       The first a reference to the data to be be validated. This can either
49       be a hash reference, or a CGI.pm-like object. In particular, the object
50       must have a param() method that works like the one in CGI.pm does.
51       CGI::Simple and Apache::Request objects are known to work in
52       particular. Note that if you use a hash reference, multiple values for
53       a single key should be presented as an array reference.
54
55       The second argument is a reference to the profile you are validating.
56
57   validate()
58           my( $valids, $missings, $invalids, $unknowns ) =
59               Data::FormValidator->validate( \%input_hash, \%dfv_profile);
60
61       "validate()" provides a deprecated alternative to "check()". It has the
62       same input syntax, but returns a four element array, described as
63       follows
64
65       valids
66           This is a hash reference to the valid fields which were submitted
67           in the data. The data may have been modified by the various filters
68           specified.
69
70       missings
71           This is a reference to an array which contains the name of the
72           missing fields. Those are the fields that the user forget to fill
73           or filled with spaces. These fields may comes from the required
74           list or the dependencies list.
75
76       invalids
77           This is a reference to an array which contains the name of the
78           fields which failed one or more of their constraint checks. If
79           there are no invalid fields, an empty arrayref will be returned.
80
81           Fields defined with multiple constraints will have an array ref
82           returned in the @invalids array instead of a string. The first
83           element in this array is the name of the field, and the remaining
84           fields are the names of the failed constraints.
85
86       unknowns
87           This is a list of fields which are unknown to the profile. Whether
88           or not this indicates an error in the user input is application
89           dependent.
90
91   new()
92       Using "new()" is only needed for advanced usage, including these cases:
93
94       o   Loading more than one profile at a time. Then you can select the
95           profile you want by name later with "check()". Here's an example:
96
97            my $dfv = Data::FormValidator->new({
98               profile_1 => { # usual profile definition here },
99               profile_2 => { # another profile definition },
100            });
101
102           As illustrated, multiple profiles are defined through a hash ref
103           whose keys point to profile definitions.
104
105           You can also load several profiles from a file, by defining several
106           profiles as shown above in an external file. Then just pass in the
107           name of the file:
108
109            my $dfv = Data::FormValidator->new('/path/to/profiles.pl');
110
111           If the input profile is specified as a file name, the profiles will
112           be reread each time that the disk copy is modified.
113
114           Now when calling "check()", you just need to supply the profile
115           name:
116
117            my $results = $dfv->check(\%input_hash,'profile_1');
118
119       o   Applying defaults to more than one input profile. There are some
120           parts of the validation profile that you might like to re-use for
121           many form validations.
122
123           To facilitate this, "new()" takes a second argument, a hash
124           reference. Here the usual input profile definitions can be made.
125           These will act as defaults for any subsequent calls to "check()" on
126           this object.
127
128           Currently the logic for this is very simple. Any definition of a
129           key in your validation profile will completely overwrite your
130           default value.
131
132           This means you can't define two keys for "constraint_regexp_map"
133           and expect they will always be there. This kind of feature may be
134           added in the future.
135
136           The exception here is definitions for your "msgs" key. You will
137           safely  be able to define some defaults for the top level keys
138           within "msgs" and not have them clobbered just because "msgs" was
139           defined in a validation profile.
140
141           One way to use this feature is to create your own sub-class that
142           always provides your defaults to "new()".
143
144           Another option is to create your own wrapper routine which provides
145           these defaults to "new()".  Here's an example of a routine you
146           might put in a CGI::Application super-class to make use of this
147           feature:
148
149            # Always use the built-in CGI object as the form data
150            # and provide some defaults to new constructor
151            sub check_form {
152                my $self = shift;
153                my $profile = shift
154                   || die 'check_form: missing required profile';
155
156                require Data::FormValidator;
157                my $dfv = Data::FormValidator->new({},{
158                   # your defaults here
159                });
160                return $dfv->check($self->query,$profile);
161            }
162

INPUT PROFILE SPECIFICATION

164       An input profile is a hash reference containing one or more of the
165       following keys.
166
167       Here is a very simple input profile. Examples of more advanced options
168       are described below.
169
170           use Data::FormValidator::Constraints qw(:closures);
171
172           my $profile = {
173               optional => [qw( company
174                                fax
175                                country )],
176
177               required => [qw( fullname
178                                phone
179                                email
180                                address )],
181
182               constraint_methods => {
183                   email => email(),
184               }
185           };
186
187       That defines some fields as optional, some as required, and defines
188       that the field named 'email' must pass the constraint named 'email'.
189
190       Here is a complete list of the keys available in the input profile,
191       with examples of each.
192
193   required
194       This is an array reference which contains the name of the fields which
195       are required. Any fields in this list which are not present or contain
196       only spaces will be reported as missing.
197
198   required_regexp
199        required_regexp => qr/city|state|zipcode/,
200
201       This is a regular expression used to specify additional field names for
202       which values will be required.
203
204   require_some
205        require_some => {
206           # require any two fields from this group
207           city_or_state_or_zipcode => [ 2, qw/city state zipcode/ ],
208        }
209
210       This is a reference to a hash which defines groups of fields where 1 or
211       more fields from the group should be required, but exactly which fields
212       doesn't matter. The keys in the hash are the group names.  These are
213       returned as "missing" unless the required number of fields from the
214       group has been filled in. The values in this hash are array references.
215       The first element in this array should be the number of fields in the
216       group that is required. If the first field in the array is not an a
217       digit, a default of "1" will be used.
218
219   optional
220        optional => [qw/meat coffee chocolate/],
221
222       This is an array reference which contains the name of optional fields.
223       These are fields which MAY be present and if they are, they will be
224       checked for valid input. Any fields not in optional or required list
225       will be reported as unknown.
226
227   optional_regexp
228        optional_regexp => qr/_province$/,
229
230       This is a regular expression used to specify additional fields which
231       are optional. For example, if you wanted all fields names that begin
232       with user_ to be optional, you could use the regular expression,
233       /^user_/
234
235   dependencies
236        dependencies   => {
237
238           # If cc_no is entered, make cc_type and cc_exp required
239           "cc_no" => [ qw( cc_type cc_exp ) ],
240
241           # if pay_type eq 'check', require check_no
242           "pay_type" => {
243               check => [ qw( check_no ) ],
244            }
245
246           # if cc_type is VISA or MASTERCARD require CVV
247           "cc_type" => sub {
248               my $dfv  = shift;
249               my $type = shift;
250
251               return [ 'cc_cvv' ] if ($type eq "VISA" || $type eq "MASTERCARD");
252               return [ ];
253           },
254        },
255
256       This is for the case where an optional field has other requirements.
257       The dependent fields can be specified with an array reference.
258
259       If the dependencies are specified with a hash reference then the
260       additional constraint is added that the optional field must equal a key
261       for the dependencies to be added.
262
263       If the dependencies are specified as a code reference then the code
264       will be executed to determine the dependent fields.  It is passed two
265       parameters, the object and the value of the field, and it should return
266       an array reference containing the list of dependent fields.
267
268       Any fields in the dependencies list that are missing when the target is
269       present will be reported as missing.
270
271   dependency_groups
272        dependency_groups  => {
273            # if either field is filled in, they all become required
274            password_group => [qw/password password_confirmation/],
275        }
276
277       This is a hash reference which contains information about groups of
278       interdependent fields. The keys are arbitrary names that you create and
279       the values are references to arrays of the field names in each group.
280
281   defaults
282        defaults => {
283            country => "USA",
284        },
285
286       This is a hash reference where keys are field names and values are
287       defaults to use if input for the field is missing.
288
289       The values can be code refs which will be used to calculate the value
290       if needed. These code refs will be passed in the DFV::Results object as
291       the only parameter.
292
293       The defaults are set shortly before the constraints are applied, and
294       will be returned with the other valid data.
295
296   defaults_regexp_map
297         defaults_regexp_map => {
298             qr/^opt_/ => 1,
299         },
300
301       This is a hash reference that maps  regular expressions to default
302       values to use for matching optional or required fields.
303
304       It's useful if you have generated many checkbox fields with the similar
305       names.  Since checkbox fields submit nothing at all when they are not
306       checked, it's useful to set defaults for them.
307
308       Note that it doesn't make sense to use a default for a field handled by
309       "optional_regexp" or "required_regexp".  When the field is not
310       submitted, there is no way to know that it should be optional or
311       required, and thus there's no way to know that a default should be set
312       for it.
313
314   filters
315        # trim leading and trailing whitespace on all fields
316        filters       => ['trim'],
317
318       This is a reference to an array of filters that will be applied to ALL
319       optional and required fields, before any constraints are applied.
320
321       This can be the name of a built-in filter (trim,digit,etc) or an
322       anonymous subroutine which should take one parameter, the field value
323       and return the (possibly) modified value.
324
325       Filters modify the data returned through the results object, so use
326       them carefully.
327
328       See Data::FormValidator::Filters for details on the built-in filters.
329
330   field_filters
331        field_filters => {
332            cc_no => ['digit'],
333        },
334
335       A hash ref with field names as keys. Values are array references of
336       built-in filters to apply (trim,digit,etc) or an anonymous subroutine
337       which should take one parameter, the field value and return the
338       (possibly) modified value.
339
340       Filters are applied before any constraints are applied.
341
342       See Data::FormValidator::Filters for details on the built-in filters.
343
344   field_filter_regexp_map
345        field_filter_regexp_map => {
346            # Upper-case the first letter of all fields that end in "_name"
347            qr/_name$/    => ['ucfirst'],
348        },
349
350       'field_filter_regexp_map' is used to apply filters to fields that match
351       a regular expression.  This is a hash reference where the keys are the
352       regular expressions to use and the values are references to arrays of
353       filters which will be applied to specific input fields. Just as with
354       'field_filters', you can you use a built-in filter or use a coderef to
355       supply your own.
356
357   constraint_methods
358        use Data::FormValidator::Constraints qw(:closures);
359
360        constraint_methods => {
361           cc_no      => cc_number({fields => ['cc_type']}),
362           cc_type    => cc_type(),
363           cc_exp     => cc_exp(),
364         },
365
366       A hash ref which contains the constraints that will be used to check
367       whether or not the field contains valid data.
368
369       Note: To use the built-in constraints, they need to first be loaded
370       into your name space using the syntax above. (Unless you are using the
371       old "constraints" key, documented in "BACKWARDS COMPATIBILITY").
372
373       The keys in this hash are field names. The values can be any of the
374       following:
375
376       o   A named constraint.
377
378           Example:
379
380            my_zipcode_field     => zip(),
381
382           See Data::FormValidator::Constraints for the details of which
383           built-in constraints that are available.
384
385       o   A perl regular expression
386
387           Example:
388
389            my_zipcode_field   => qr/^\d{5}$/, # match exactly 5 digits
390
391           If this field is named in "untaint_constraint_fields" or
392           "untaint_regexp_map", or "untaint_all_constraints" is effective, be
393           aware of the following: If you write your own regular expressions
394           and only match part of the string then you'll only get part of the
395           string in the valid hash. It is a good idea to write you own
396           constraints like /^regex$/. That way you match the whole string.
397
398       o   a subroutine reference, to supply custom code
399
400           This will check the input and return true or false depending on the
401           input's validity.  By default, the constraint function receives a
402           Data::FormValidator::Results object as its first argument, and the
403           value to be validated as the second.  To validate a field based on
404           more inputs than just the field itself, see "VALIDATING INPUT BASED
405           ON MULTIPLE FIELDS".
406
407           Examples:
408
409            # Notice the use of 'pop'--
410            # the object is the first arg passed to the method
411            # while the value is the second, and last arg.
412            my_zipcode_field => sub { my $val = pop;  return $val =~ '/^\d{5}$/' },
413
414            # OR you can reference a subroutine, which should work like the one above
415            my_zipcode_field => \&my_validation_routine,
416
417            # An example of setting the constraint name.
418            my_zipcode_field => sub {
419               my ($dfv, $val) = @_;
420               $dfv->set_current_constraint_name('my_constraint_name');
421               return $val =~ '/^\d{5}$/'
422            },
423
424       o   an array reference
425
426           An array reference is used to apply multiple constraints to a
427           single field. Any of the above options are valid entries the array.
428           See "MULTIPLE CONSTRAINTS" below.
429
430           For more details see "VALIDATING INPUT BASED ON MULTIPLE FIELDS".
431
432   constraint_method_regexp_map
433        use Data::FormValidator::Constraints qw(:closures);
434
435        # In your profile.
436        constraint_method_regexp_map => {
437            # All fields that end in _postcode have the 'postcode' constraint applied.
438            qr/_postcode$/    => postcode(),
439        },
440
441       A hash ref where the keys are the regular expressions to use and the
442       values are the constraints to apply.
443
444       If one or more constraints have already been defined for a given field
445       using "constraint_methods", "constraint_method_regexp_map" will add an
446       additional constraint for that field for each regular expression that
447       matches.
448
449   untaint_all_constraints
450        untaint_all_constraints => 1,
451
452       If this field is set, all form data that passes a constraint will be
453       untainted.  The untainted data will be returned in the valid hash.
454       Untainting is based on the pattern match used by the constraint.  Note
455       that some constraint routines may not provide untainting.
456
457       See Writing your own constraint routines for more information.
458
459       This is overridden by "untaint_constraint_fields" and
460       "untaint_regexp_map".
461
462   untaint_constraint_fields
463        untaint_constraint_fields => [qw(zipcode state)],
464
465       Specifies that one or more fields will be untainted if they pass their
466       constraint(s). This can be set to a single field name or an array
467       reference of field names. The untainted data will be returned in the
468       valid hash.
469
470       This overrides the untaint_all_constraints flag.
471
472   untaint_regexp_map
473        untaint_regexp_map => [qr/some_field_\d/],
474
475       Specifies that certain fields will be untainted if they pass their
476       constraints and match one of the regular expressions supplied. This can
477       be set to a single regex, or an array reference of regexes. The
478       untainted data will be returned in the valid hash.
479
480       The above example would untaint the fields named "some_field_1", and
481       "some_field_2" but not "some_field".
482
483       This overrides the untaint_all_constraints flag.
484
485   missing_optional_valid
486        missing_optional_valid => 1
487
488       This can be set to a true value to cause optional fields with empty
489       values to be included in the valid hash. By default they are not
490       included-- this is the historical behavior.
491
492       This is an important flag if you are using the contents of an "update"
493       form to update a record in a database. Without using the option, fields
494       that have been set back to "blank" may fail to get updated.
495
496   validator_packages
497        # load all the constraints and filters from these modules
498        validator_packages => [qw(Data::FormValidator::Constraints::Upload)],
499
500       This key is used to define other packages which contain constraint
501       routines or filters.  Set this key to a single package name, or an
502       arrayref of several. All of its constraint and filter routines
503       beginning with 'match_', 'valid_' and 'filter_' will be imported into
504       Data::FormValidator.  This lets you reference them in a constraint with
505       just their name, just like built-in routines.  You can even override
506       the provided validators.
507
508       See Writing your own constraint routines documentation for more
509       information
510
511   msgs
512       This key is used to define parameters related to formatting error
513       messages returned to the user.
514
515       By default, invalid fields have the message "Invalid" associated with
516       them while missing fields have the message "Missing" associated with
517       them.
518
519       In the simplest case, nothing needs to be defined here, and the default
520       values will be used.
521
522       The default formatting applied is designed for display in an XHTML web
523       page.  That formatting is as followings:
524
525           <span style="color:red;font-weight:bold" class="dfv_errors">* %s</span>
526
527       The %s will be replaced with the message. The effect is that the
528       message will appear in bold red with an asterisk before it. This style
529       can be overridden by simply defining "dfv_errors" appropriately in a
530       style sheet, or by providing a new format string.
531
532       Here's a more complex example that shows how to provide your own
533       default message strings, as well as providing custom messages per
534       field, and handling multiple constraints:
535
536        msgs => {
537
538            # set a custom error prefix, defaults to none
539            prefix=> 'error_',
540
541            # Set your own "Missing" message, defaults to "Missing"
542            missing => 'Not Here!',
543
544            # Default invalid message, default's to "Invalid"
545            invalid => 'Problematic!',
546
547            # message separator for multiple messages
548            # Defaults to ' '
549            invalid_separator => ' <br /> ',
550
551            # formatting string, default given above.
552            format => 'ERROR: %s',
553
554            # Error messages, keyed by constraint name
555            # Your constraints must be named to use this.
556            constraints => {
557                            'date_and_time' => 'Not a valid time format',
558                            # ...
559            },
560
561            # This token will be included in the hash if there are
562            # any errors returned. This can be useful with templating
563            # systems like HTML::Template
564            # The 'prefix' setting does not apply here.
565            # defaults to undefined
566            any_errors => 'some_errors',
567        }
568
569       The hash that's prepared can be retrieved through the "msgs" method
570       described in the Data::FormValidator::Results documentation.
571
572   msgs - callback
573       This is a new feature. While it expected to be forward-compatible, it
574       hasn't yet received the testing the rest of the API has.
575
576       If the built-in message generation doesn't suit you, it is also
577       possible to provide your own by specifying a code reference:
578
579        msgs  =>  \&my_msgs_callback
580
581       This will be called as a Data::FormValidator::Results method.  It may
582       receive as arguments an additional hash reference of control
583       parameters, corresponding to the key names usually used in the "msgs"
584       area of the profile. You can ignore this information if you'd like.
585
586       If you have an alternative error message handler you'd like to share,
587       stick in the "Data::FormValidator::ErrMsgs" name space and upload it to
588       CPAN.
589
590   debug
591       This method is used to print details about what is going on to STDERR.
592
593       Currently only level '1' is used. It provides information about which
594       fields matched constraint_regexp_map.
595
596   A shortcut for array refs
597       A number of parts of the input profile specification include array
598       references as their values.  In any of these places, you can simply use
599       a string if you only need to specify one value. For example, instead of
600
601        filters => [ 'trim' ]
602
603       you can simply say
604
605        filters => 'trim'
606
607   A note on regular expression formats
608       In addition to using the preferred method of defining regular
609       expressions using "qr", a deprecated style of defining them as strings
610       is also supported.
611
612       Preferred:
613
614        qr/this is great/
615
616       Deprecated, but supported
617
618        'm/this still works/'
619

VALIDATING INPUT BASED ON MULTIPLE FIELDS

621       You can pass more than one value into a constraint routine.  For that,
622       the value of the constraint should be a hash reference. If you are
623       creating your own routines, be sure to read the section labeled
624       "WRITING YOUR OWN CONSTRAINT ROUTINES", in the
625       Data::FormValidator::Constraints documentation.  It describes a newer
626       and more flexible syntax.
627
628       Using the original syntax, one key should be named "constraint" and
629       should have a value set to the reference of the subroutine or the name
630       of a built-in validator.  Another required key is "params". The value
631       of the "params" key is a reference to an array of the other elements to
632       use in the validation. If the element is a scalar, it is assumed to be
633       a field name. The field is known to Data::FormValidator, the value will
634       be filtered through any defined filters before it is passed in.  If the
635       value is a reference, the reference is passed directly to the routine.
636       Don't forget to include the name of the field to check in that list, if
637       you are using this syntax.
638
639       Example:
640
641        cc_no  => {
642            constraint  => "cc_number",
643            params         => [ qw( cc_no cc_type ) ],
644        },
645

MULTIPLE CONSTRAINTS

647       Multiple constraints can be applied to a single field by defining the
648       value of the constraint to be an array reference. Each of the values in
649       this array can be any of the constraint types defined above.
650
651       When using multiple constraints it is important to return the name of
652       the constraint that failed so you can distinguish between them. To do
653       that, either use a named constraint, or use the hash ref method of
654       defining a constraint and include a "name" key with a value set to the
655       name of your constraint.  Here's an example:
656
657        my_zipcode_field => [
658            'zip',
659            {
660              constraint =>  '/^406/',
661              name        =>  'starts_with_406',
662            }
663        ],
664
665       You can use an array reference with a single constraint in it if you
666       just want to have the name of your failed constraint returned in the
667       above fashion.
668
669       Read about the "validate()" function above to see how multiple
670       constraints are returned differently with that method.
671

ADVANCED VALIDATION

673       For even more advanced validation, you will likely want to read the
674       documentation for other modules in this distribution, linked below.
675       Also keep in mind that the  Data::FormValidator profile structure is
676       just another data structure. There is no reason why it needs to be
677       defined statically. The profile could also be built on the fly with
678       custom Perl code.
679

BACKWARDS COMPATIBILITY

681   validate()
682           my( $valids, $missings, $invalids, $unknowns ) =
683               Data::FormValidator->validate( \%input_hash, \%dfv_profile);
684
685       "validate()" provides a deprecated alternative to "check()". It has the
686       same input syntax, but returns a four element array, described as
687       follows
688
689       valids
690           This is a hash reference to the valid fields which were submitted
691           in the data. The data may have been modified by the various filters
692           specified.
693
694       missings
695           This is a reference to an array which contains the name of the
696           missing fields. Those are the fields that the user forget to fill
697           or filled with spaces. These fields may comes from the required
698           list or the dependencies list.
699
700       invalids
701           This is a reference to an array which contains the name of the
702           fields which failed one or more of their constraint checks.
703
704           Fields defined with multiple constraints will have an array ref
705           returned in the @invalids array instead of a string. The first
706           element in this array is the name of the field, and the remaining
707           fields are the names of the failed constraints.
708
709       unknowns
710           This is a list of fields which are unknown to the profile. Whether
711           or not this indicates an error in the user input is application
712           dependent.
713
714   constraints (profile key)
715       This is a supported but deprecated profile key. Using
716       "constraint_methods" is recommended instead, which provides a simpler,
717       more versatile interface.
718
719        constraints => {
720           cc_no      => {
721               constraint  => "cc_number",
722               params        => [ qw( cc_no cc_type ) ],
723           },
724           cc_type    => "cc_type",
725           cc_exp    => "cc_exp",
726         },
727
728       A hash ref which contains the constraints that will be used to check
729       whether or not the field contains valid data.
730
731       The keys in this hash are field names. The values can be any of the
732       following:
733
734       o   A named constraint.
735
736           Example:
737
738            my_zipcode_field     => 'zip',
739
740           See Data::FormValidator::Constraints for the details of which
741           built-in constraints that are available.
742
743   hashref style of specifying constraints
744       Using a hash reference to specify a constraint is an older technique
745       used to name a constraint or supply multiple parameters.
746
747       Both of these interface issues are now better addressed with
748       "constraint_methods" and "$self-\"name_this('foo')>.
749
750        # supply multiple parameters
751        cc_no  => {
752            constraint  => "cc_number",
753            params      => [ qw( cc_no cc_type ) ],
754        },
755
756        # name a constraint, useful for returning error messages
757        last_name => {
758            name => "ends_in_name",
759            constraint => qr/_name$/,
760        },
761
762       Using a hash reference for a constraint permits the passing of multiple
763       arguments. Required arguments are "constraint" or "constraint_method".
764       Optional arguments are "name" and "params".
765
766       A "name" on a constraints 'glues' the constraint to its error message
767       in the validator profile (refer "msgs" section below). If no "name" is
768       given then it will default to the value of "constraint" or
769       "constraint_method" IF they are NOT a CODE ref or a RegExp ref.
770
771       The "params" value is a reference to an array of the parameters to pass
772       to the constraint method.  If an element of the "params" list is a
773       scalar, it is assumed to be naming a key of the %input_hash and that
774       value is passed to the routine.  If the parameter is a reference, then
775       it is treated literally and passed unchanged to the routine.
776
777       If you are using the older "constraint" over the new
778       "constraint_method" then don't forget to include the name of the field
779       to check in the "params" list. "constraint_method" provides access to
780       this value via the "get_current_*" methods (refer
781       Data::FormValidator::Constraints)
782
783       For more details see "VALIDATING INPUT BASED ON MULTIPLE FIELDS".
784
785   constraint_regexp_map (profile key)
786       This is a supported by deprecated profile key. Using
787       "constraint_methods_regexp_map" is recommended instead.
788
789        constraint_regexp_map => {
790            # All fields that end in _postcode have the 'postcode' constraint applied.
791            qr/_postcode$/    => 'postcode',
792        },
793
794       A hash ref where the keys are the regular expressions to use and the
795       values are the constraints to apply.
796
797       If one or more constraints have already been defined for a given field
798       using "constraints", constraint_regexp_map will add an additional
799       constraint for that field for each regular expression that matches.
800

SEE ALSO

802       Other modules in this distribution:
803
804       Data::FormValidator::Constraints
805
806       Data::FormValidator::Constraints::Dates
807
808       Data::FormValidator::Constraints::Upload
809
810       Data::FormValidator::ConstraintsFactory
811
812       Data::FormValidator::Filters
813
814       Data::FormValidator::Results
815
816       A sample application by the maintainer:
817
818       Validating Web Forms with Perl,
819       http://mark.stosberg.com/Tech/perl/form-validation/
820       <http://mark.stosberg.com/Tech/perl/form-validation/>
821
822       Related modules:
823
824       Data::FormValidator::Tutorial
825
826       Data::FormValidator::Util::HTML
827
828       CGI::Application::ValidateRM, a CGI::Application & Data::FormValidator
829       glue module
830
831       HTML::Template::Associate::FormValidator is designed to make some kinds
832       of integration with HTML::Template easier.
833
834       Params::Validate is useful for validating function parameters.
835
836       Regexp::Common, Data::Types, Data::Verify, Email::Valid,
837       String::Checker, CGI::ArgChecker, CGI::FormMagick::Validator,
838       CGI::Validate
839
840       Document Translations:
841
842       Japanese: <http://perldoc.jp/docs/modules/>
843
844       Distributions which include Data::FormValidator
845
846       FreeBSD includes a port named p5-Data-FormValidator
847
848       Debian GNU/Linux includes a port named libdata-formvalidator-perl
849

CREDITS

851       Some of those input validation functions have been taken from MiniVend
852       by Michael J. Heins.
853
854       The credit card checksum validation was taken from contribution by
855       Bruce Albrecht to the MiniVend program.
856

BUGS

858       Bug reports and patches are welcome. Reports which include a failing
859       Test::More style test are helpful will receive priority.
860
861       http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-FormValidator
862       <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-FormValidator>
863

CONTRIBUTING

865       This project is managed using the darcs source control system (
866       http://www.darcs.net/ ). My darcs archive is here:
867       http://mark.stosberg.com/darcs_hive/dfv/
868
869       Support Mailing List
870
871       If you have any questions, comments, or feature suggestions, post them
872       to the support mailing list!  To join the mailing list, visit
873
874       http://lists.sourceforge.net/lists/listinfo/cascade-dataform
875       <http://lists.sourceforge.net/lists/listinfo/cascade-dataform>
876
877       Messages about DFV sent directly to the maintainer may be redirected
878       here.
879

AUTHOR

881       Parts Copyright 2001-2006 by Mark Stosberg <mark at summersault.com>,
882       (Current Maintainer)
883
884       Copyright (c) 1999 Francis J. Lacoste and iNsu Innovations Inc.  All
885       rights reserved.  (Original Author)
886
887       Parts Copyright 1996-1999 by Michael J. Heins <mike@heins.net>
888
889       Parts Copyright 1996-1999 by Bruce Albrecht
890       <bruce.albrecht@seag.fingerhut.com>
891

LICENSE

893       This program is free software; you can redistribute it and/or modify it
894       under the terms as perl itself.
895
896
897
898perl v5.12.3                      2011-08-28            Data::FormValidator(3)
Impressum