The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTML::FormFu::Constraint - Constrain User Input

SYNOPSIS

    ---
    elements: 
      - type: Text
        name: foo
        constraints:
          - type: Length
            min: 8
      - type: Text
        name: bar
        constraints: 
          - Integer
          - Required
    constraints: 
      - SingleValue

DESCRIPTION

User input is processed in the following order: Filters, Constraints, Inflators, Validators, Transformers - see "FORM LOGIC AND VALIDATION" in HTML::FormFu for further details.

"constraints" in HTML::FormFu can be called on any form, block element (includes fieldsets) or field element.

If called on a field element, no name argument should be passed.

If called on a form or block element, if no name argument is provided, a new constraint is created for and added to every field on that form or block.

See "FORM LOGIC AND VALIDATION" in HTML::FormFu for further details.

METHODS

type

Returns the type argument originally used to create the constraint.

not

If true, inverts the results of the constraint - such that input that would otherwise fail will pass, and vise-versa.

This value is ignored by some constraints - see the documentation for individual constraints for details.

message

Arguments: $string

Set the message which will be displayed if the constraint fails.

message_xml

Arguments: $string

Variant of "message" which ensures the value won't be XML-escaped.

message_loc

Arguments: $string

Variant of "message" which uses localize to create the message.

localise_args

Provide arguments that should be passed to localize to replace [_1], [_2], etc. in the localized string.

parent

Returns the HTML::FormFu::Element::_Field object that the constraint is associated with.

form

Returns the HTML::FormFu object that the constraint's field is attached to.

name

Shorthand for $constraint->parent->name

CORE CONSTRAINTS

HTML::FormFu::Constraint::AllOrNone
HTML::FormFu::Constraint::ASCII
HTML::FormFu::Constraint::AutoSet
HTML::FormFu::Constraint::Bool
HTML::FormFu::Constraint::Callback
HTML::FormFu::Constraint::CallbackOnce
HTML::FormFu::Constraint::DependOn
HTML::FormFu::Constraint::Email
HTML::FormFu::Constraint::Equal
HTML::FormFu::Constraint::Integer
HTML::FormFu::Constraint::Length
HTML::FormFu::Constraint::MaxLength
HTML::FormFu::Constraint::MinLength
HTML::FormFu::Constraint::MinMaxFields
HTML::FormFu::Constraint::Number
HTML::FormFu::Constraint::Printable
HTML::FormFu::Constraint::Range
HTML::FormFu::Constraint::Regex
HTML::FormFu::Constraint::Required
HTML::FormFu::Constraint::Set
HTML::FormFu::Constraint::SingleValue
HTML::FormFu::Constraint::Word

AUTHOR

Carl Franks, cfranks@cpan.org

Based on the original source code of HTML::Widget::Constraint, by Sebastian Riedel, sri@oook.de.

LICENSE

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.