HTML::...:Types(3pm)
π HTML::FormHandler::Types β the Moose type constraints one (3pm)
okay so bestie, this is the HTML::FormHandler::Types page from the User Contributed Perl Documentation, and it's literally just type constraints. Moose type constraints. That's the whole vibe. Let's get into it π«Ά
β¨ VERSION β¨
version 0.40068 β yes it's a whole version number, we love a numbered era π
πΈ SYNOPSIS πΈ
okay so here's the thing that trips everyone up: these types are provided by MooseX::Types. and these types must not be quoted when you use them. no quotes. none. periodt.
has 'posint' => ( is => 'rw', isa => PositiveInt);
has_field 'email' => ( apply => [ Email ] );
but!! types declared using Moose::Util::TypeConstraints, on the other hand, must be quoted. yes this is inconsistent, no I don't make the rules π
has_field 'text_both' => ( apply => [ PositiveInt, 'GreaterThan10' ] );
and to import these types into your forms, you gotta either specify (':all') or list out the types you actually want. main character energy only:
use HTML::FormHandler::Types (':all');
or, if you're being picky (respect):
use HTML::FormHandler::Types ('Email', 'PositiveInt');
π¦ DESCRIPTION π¦
ngl, it would be possible to import the MooseX types (Common, etc), but for now they're just re-implementing them right here in this module. why? so they can change the messages and keep control of what types they provide. control is the vibe, we stan π
From MooseX::Types::Common:
'PositiveNum', 'PositiveInt', 'NegativeNum', 'NegativeInt', 'SingleDigit',
'SimpleStr', 'NonEmptySimpleStr', 'Password', 'StrongPassword', 'NonEmptyStr',
π Type Constraints π
these types check the value and issue an error message. so like, they're the ones who will call you out. lovingly. π₯
- Email β uses
Email::Valid - State β checks that the state is in a list of two uppercase letters
- Zip β literally no description given in the original, it's giving mystery π
- IPAddress β must be a valid IPv4 address
- NoSpaces β no spaces in string allowed
- WordChars β must be made up of letters, digits, and underscores
- NotAllDigits β might be useful for passwords π
- Printable β must not contain non-printable characters
- SingleWord β contains a single word
π§ Type Coercions π§
these types will transform the value without an error message. no scolding, just glow-up β¨
- Collapse β replaces multiple spaces with a single space
- Upper β makes the string all upper case
- Lower β makes the string all lower case
- Trim β trims the string of starting and ending spaces
π AUTHOR π
FormHandler Contributors β see HTML::FormHandler
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2017 by Gerda Shank.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
fr fr that's the whole page, no cap. go forth and type-constrain responsibly π
and that's a wrap bestie!! this was HTML::...:Types(3pm) from the User Contributed Perl Documentation, perl v5.34.0, dated 2022-03-25 β mwah, slay, bye ππ¦
π¦ where this page comes from
- debian bookworm: libhtml-formhandler-perl 0.40068-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libhtml-formhandler-perl 0.40068-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-formhandler-perl 0.40068-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-formhandler-perl 0.40068-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms