MooseX...:String(3pm)

πŸ’– MooseX::Types::Common::String πŸ’–

okay bestie so this is a page from the User Contributed Perl Documentation, and it's all about MooseX::Types::Common::String β€” the little gem that hands you the string types Moose forgot to pack. ✨


🌸 VERSION 🌸

version 0.001015 β€” yeah she's on 0.001015, no cap πŸ’…


✨ SYNOPSIS ✨

use MooseX::Types::Common::String qw/SimpleStr/;
has short_str => (is => 'rw', isa => SimpleStr);

...
#this will fail
$object->short_str("string\nwith\nbreaks");

so like. you pull in SimpleStr, you slap it on an attribute, and then the moment somebody tries to sneak a newline into short_str? πŸš«πŸ’€ it just fails. the vibe check is brutal and honestly? iconic.


πŸ¦‹ DESCRIPTION πŸ¦‹

a whole squad of string type constraints that are lowkey useful but do not ship with Moose by default. let's meet the girlies one by one:

  • SimpleStr β€” a Str with no new-line characters and length <= 255. she's simple, she's clean, she does not do multi-line drama πŸ™…β€β™€οΈ
  • NonEmptySimpleStr β€” a SimpleStr with length > 0. literally the same girl but she refuses to be nothing. main character energy fr.
  • LowerCaseSimpleStr β€” a NonEmptySimpleStr with no uppercase characters. and yes, a coercion exists via lc from NonEmptySimpleStr β€” so she'll quietly lowercase herself for you πŸ₯°
  • UpperCaseSimpleStr β€” a NonEmptySimpleStr with no lowercase characters. a coercion exists via uc from NonEmptySimpleStr, so she can YELL FOR YOU TOO πŸ“£
  • Password β€” a NonEmptySimpleStr with length > 3. short king passwords stay OUT πŸ”
  • StrongPassword β€” a NonEmptySimpleStr with length > 7 that contains at least one non-alpha character. so like, numbers or symbols, bestie, she has standards πŸ’ͺ
  • NonEmptyStr β€” a Str with length > 0. plain, honest, not empty. periodt.
  • LowerCaseStr β€” a Str with length > 0 and no uppercase characters. a coercion exists via lc from NonEmptyStr. πŸ“
  • UpperCaseStr β€” a Str with length > 0 and no lowercase characters. a coercion exists via uc from NonEmptyStr. πŸ“
  • NumericCode β€” a Str with no new-line characters that consists of only Numeric characters. examples include Social Security Numbers, Personal Identification Numbers, Postal Codes, HTTP Status Codes, etc. and here's the cute part β€” she supports attempting to coerce from a string that has punctuation or whitespaces in it ( e.g credit card number 4111-1111-1111-1111 ). so messy input gets cleaned up, we love a glow-up ✨

πŸ‘‘ SEE ALSO πŸ‘‘

  • MooseX::Types::Common::Numeric β€” her sibling, go say hi πŸ’œ

🫢 SUPPORT 🫢

bugs may be submitted through the RT bug tracker at https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types-Common (or email bug-MooseX-Types-Common@rt.cpan.org). they will actually read it, promise πŸ™ˆ

there is also a mailing list available for users of this distribution, at http://lists.perl.org/list/moose.html. join the chat, it's a good time 🌈

there is also an irc channel available for users of this distribution, at #moose on irc.perl.org (irc://irc.perl.org/#moose). come hang out, the moose girlies are so sweet πŸ’–


🌟 AUTHORS 🌟

the absolute legends who made this happen:

  • Matt S Trout - mst (at) shadowcat.co.uk (https://www.shadowcat.co.uk/)
  • K. James Cheetham <jamie@shadowcat.co.uk>
  • Guillermo Roditi <groditi@gmail.com>

this software is copyright (c) 2009 by Matt S Trout - mst (at) shadowcat.co.uk (https://www.shadowcat.co.uk/).

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay, legally speaking βš–οΈβœ¨


okay that's the whole page bestie, no skips no cap πŸ’œ and just so you know where this came from β€” it's perl v5.40.1, dated 2025-04-24, and the manual is MooseX...:String(3pm). bye pookie, go write some typed attributes πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from