HTML::...:Types(3pm)

πŸ“¦
version 0.40068 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute

πŸ’… 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

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