1Data::FormValidator::ReUssuelrtsC(o3n)tributed Perl DocuDmaetnat:a:tFioornmValidator::Results(3)
2
3
4

NAME

6       Data::FormValidator::Results - results of form input validation.
7

SYNOPSIS

9           my $results = Data::FormValidator->check(\%input_hash, \%dfv_profile);
10
11           # Print the name of missing fields
12           if ( $results->has_missing ) {
13           for my $f ( $results->missing ) {
14               print $f, " is missing\n";
15           }
16           }
17
18           # Print the name of invalid fields
19           if ( $results->has_invalid ) {
20           for my $f ( $results->invalid ) {
21               print $f, " is invalid: ", $results->invalid( $f ), "\n";
22           }
23           }
24
25           # Print unknown fields
26           if ( $results->has_unknown ) {
27           for my $f ( $results->unknown ) {
28               print $f, " is unknown\n";
29           }
30           }
31
32           # Print valid fields
33           for my $f ( $results->valid() ) {
34               print $f, " =  ", $results->valid( $f ), "\n";
35           }
36

DESCRIPTION

38       This object is returned by the Data::FormValidator "check" method.  It
39       can be queried for information about the validation results.
40

success();

42       This method returns true if there were no invalid or missing fields,
43       else it returns false.
44
45       As a shorthand, When the $results object is used in boolean context, it
46       is overloaded to use the value of success() instead. That allows
47       creation of a syntax like this one used in
48       "CGI::Application::Plugin::ValidateRM":
49
50        my $results = $self->check_rm('form_display','_form_profile') || return $self->dfv_error_page;
51

valid( [[field] [, value]] );

53       In list context with no arguments, it returns the list of fields which
54       contain valid values:
55
56        @all_valid_field_names = $r->valid;
57
58       In a scalar context with no arguments, it returns an hash reference
59       which contains the valid fields as keys and their input as values:
60
61        $all_valid_href = $r->valid;
62
63       If called with one argument in scalar context, it returns the value of
64       that "field" if it contains valid data, "undef" otherwise. The value
65       will be an array ref if the field had multiple values:
66
67        $value = $r->valid('field');
68
69       If called with one argument in list context, it returns the values of
70       "field" as an array:
71
72        @values = $r->valid('field');
73
74       If called with two arguments, it sets "field" to "value" and returns
75       "value".  This form is useful to alter the results from within some
76       constraints.  See the Data::FormValidator::Constraints documentation.
77
78        $new_value = $r->valid('field',$new_value);
79

has_missing()

81       This method returns true if the results contain missing fields.
82

missing( [field] )

84       In list context it returns the list of fields which are missing.  In a
85       scalar context, it returns an array reference to the list of missing
86       fields.
87
88       If called with an argument, it returns true if that "field" is missing,
89       undef otherwise.
90

has_invalid()

92       This method returns true if the results contain fields with invalid
93       data.
94

invalid( [field] )

96       In list context, it returns the list of fields which contains invalid
97       value.
98
99       In a scalar context, it returns an hash reference which contains the
100       invalid fields as keys, and references to arrays of failed constraints
101       as values.
102
103       If called with an argument, it returns the reference to an array of
104       failed constraints for "field".
105

has_unknown()

107       This method returns true if the results contain unknown fields.
108

unknown( [field] )

110       In list context, it returns the list of fields which are unknown.  In a
111       scalar context, it returns an hash reference which contains the unknown
112       fields and their values.
113
114       If called with an argument, it returns the value of that "field" if it
115       is unknown, undef otherwise.
116

msgs([config parameters])

118       This method returns a hash reference to error messages. The exact
119       format is determined by parameters in the "msgs" area of the validation
120       profile, described in the Data::FormValidator documentation.
121
122       NOTE: the "msgs" parameter in the profile can take a code reference as
123       a value, allowing complete control of how messages are generated. If
124       such a code reference was provided there, it will be called here
125       instead of the usual processing, described below. It will receive as
126       arguments the Data::FormValidator::Results object and a hash reference
127       of control parameters.
128
129       The hashref passed in should contain the same options that you can
130       define in the validation profile. This allows you to separate the
131       controls for message display from the rest of the profile. While
132       validation profiles may be different for every form, you may wish to
133       format messages the same way across many projects.
134
135       Controls passed into the <msgs> method will be applied first, followed
136       by ones applied in the profile. This allows you to keep the controls
137       you pass to "msgs" as "global" and override them in a specific profile
138       if needed.
139

meta()

141       In a few cases, a constraint may discover meta data that is useful to
142       access later. For example, when using
143       Data::FormValidator::Constraints::Upload, several bits of meta data are
144       discovered about files in the process of validating. These can include
145       "bytes", "width", "height" and "extension".  The "meta()" function is
146       used by constraint methods to set this data. It's also used to access
147       this data. Here are some examples.
148
149        # return all field names that have meta data
150        my @fields = $results->meta();
151
152        # To retrieve all meta data for a field:
153        $meta_href = $results->meta('img');
154
155        # Access a particular piece:
156        $width = $results->meta('img')->{width};
157
158       Here's how to set some meta data. This is useful to know if you are
159       writing your own complex constraint.
160
161           $self->meta('img', {
162               width  => '50',
163               height => '60',
164           });
165
166       This function does not currently support multi-valued fields. If it
167       does in the future, the above syntax will still work.
168

SEE ALSO

170       Data::FormValidator, Data::FormValidator::Filters,
171       Data::FormValidator::Constraints,
172       Data::FormValidator::ConstraintsFactory
173

AUTHOR

175       Author: Francis J. Lacoste <francis.lacoste@iNsu.COM> Maintainer: Mark
176       Stosberg <mark@summersault.com>
177
179       Copyright (c) 1999,2000 iNsu Innovations Inc.  All rights reserved.
180
181       This program is free software; you can redistribute it and/or modify it
182       under the terms as perl itself.
183
184
185
186perl v5.28.0                      2018-07-14   Data::FormValidator::Results(3)
Impressum