1HTML::FormFu::ConstrainUts(e3r)Contributed Perl DocumentHaTtMiLo:n:FormFu::Constraint(3)
2
3
4

NAME

6       HTML::FormFu::Constraint - Constrain User Input
7

SYNOPSIS

9           ---
10           elements:
11             - type: Text
12               name: foo
13               constraints:
14                 - type: Length
15                   min: 8
16                   when:
17                     field: bar
18                     values: [ 1, 3, 5 ]
19             - type: Text
20               name: bar
21               constraints:
22                 - Integer
23                 - Required
24           constraints:
25             - SingleValue
26

DESCRIPTION

28       User input is processed in the following order:
29
30       Filters
31       Constraints
32       Inflators
33       Validators
34       Transformers
35
36       See "FORM LOGIC AND VALIDATION" in HTML::FormFu for further details.
37
38       "constraints" in HTML::FormFu can be called on any form, block element
39       (includes fieldsets) or field element.
40
41       If called on a field element, no "name" argument should be passed.
42
43       If called on a form or block element, if no "name" argument is
44       provided, a new constraint is created for and added to every field on
45       that form or block.
46
47       See "FORM LOGIC AND VALIDATION" in HTML::FormFu for further details.
48

METHODS

50   type
51       Returns the "type" argument originally used to create the constraint.
52
53   not
54       If true, inverts the results of the constraint - such that input that
55       would otherwise fail will pass, and vise-versa.
56
57       This value is ignored by some constraints - see the documentation for
58       individual constraints for details.
59
60   only_on_reps
61       Argument: \@repeatable_count
62
63       For constraints added to fields within a Repeatable element, if
64       "only_on_reps" is set, the constraint will only be run for fields whose
65       repeatable_count matches one of these set values.
66
67       Not available for the constraints listed in "Unsupported Constraints"
68       in HTML::FormFu::Element::Repeatable.
69
70   message
71       Arguments: $string
72
73       Set the message which will be displayed if the constraint fails.
74
75   message_xml
76       Arguments: $string
77
78       Variant of "message" which ensures the value won't be XML-escaped.
79
80   message_loc
81       Arguments: $string
82
83       Variant of "message" which uses localize to create the message.
84
85   localize_args
86       Provide arguments that should be passed to localize to replace "[_1]",
87       "[_2]", etc. in the localized string.
88
89   force_errors
90       See "force_errors" in HTML::FormFu for details.
91
92   parent
93       Returns the field object that the constraint is associated with.
94
95   form
96       Returns the HTML::FormFu object that the constraint's field is attached
97       to.
98
99   name
100       Shorthand for "$constraint->parent->name"
101
102   when
103       Defines a condition for the constraint. Only when the condition is
104       fullfilled the constraint will be applied.
105
106       This method expects a hashref.
107
108       The "field" or "callback" must be supplied, all other fields are
109       optional.
110
111       If "value" or "values" is not supplied, the constraint will pass if the
112       named field's value is true.
113
114       The following keys are supported:
115
116       field
117           nested-name of form field that shall be checked against
118
119       value
120           Expected value in the form field 'field'
121
122       values
123           Array of multiple values, one must match to fullfill the condition
124
125       not Inverts the when condition - value(s) must not match
126
127       callback
128           A callback subroutine-reference or fully resolved subroutine name
129           can be supplied to perform complex checks. An hashref of all
130           parameters is passed to the callback sub. In this case all other
131           keys are ignored, including not.  You need to return a true value
132           for the constraint to be applied or a false value to not apply it.
133

CORE CONSTRAINTS

135       HTML::FormFu::Constraint::AllOrNone
136       HTML::FormFu::Constraint::ASCII
137       HTML::FormFu::Constraint::AutoSet
138       HTML::FormFu::Constraint::Bool
139       HTML::FormFu::Constraint::Callback
140       HTML::FormFu::Constraint::CallbackOnce
141       HTML::FormFu::Constraint::DateTime
142       HTML::FormFu::Constraint::DependOn
143       HTML::FormFu::Constraint::Email
144       HTML::FormFu::Constraint::Equal
145       HTML::FormFu::Constraint::File
146       HTML::FormFu::Constraint::File::MIME
147       HTML::FormFu::Constraint::File::MaxSize
148       HTML::FormFu::Constraint::File::MinSize
149       HTML::FormFu::Constraint::File::Size
150       HTML::FormFu::Constraint::Integer
151       HTML::FormFu::Constraint::Length
152       HTML::FormFu::Constraint::MaxLength
153       HTML::FormFu::Constraint::MaxRange
154       HTML::FormFu::Constraint::MinLength
155       HTML::FormFu::Constraint::MinRange
156       HTML::FormFu::Constraint::MinMaxFields
157       HTML::FormFu::Constraint::Number
158       HTML::FormFu::Constraint::Printable
159       HTML::FormFu::Constraint::Range
160       HTML::FormFu::Constraint::reCAPTCHA
161       HTML::FormFu::Constraint::Regex
162       HTML::FormFu::Constraint::Required
163       HTML::FormFu::Constraint::Set
164       HTML::FormFu::Constraint::SingleValue
165       HTML::FormFu::Constraint::Word
166

CAVEATS

168       See "Unsupported Constraints" in HTML::FormFu::Element::Repeatable for
169       a list of constraints that won't work within
170       HTML::FormFu::Element::Repeatable.
171

AUTHOR

173       Carl Franks, "cfranks@cpan.org"
174
175       Based on the original source code of HTML::Widget::Constraint, by
176       Sebastian Riedel, "sri@oook.de".
177

LICENSE

179       This library is free software, you can redistribute it and/or modify it
180       under the same terms as Perl itself.
181
182
183
184perl v5.12.1                      2010-05-23       HTML::FormFu::Constraint(3)
Impressum