Types::...StrMatch(3)

πŸ’– Types::...StrMatch(3) πŸ’–

Spotted in the wild under User Contributed Perl Documentation β€” and yes, bestie, we're getting into Types::Standard::StrMatch together. It's giving exporter-utility realness, so grab a strawberry drink and let's go πŸ“βœ¨


🌸 NAME 🌸

Types::Standard::StrMatch β€” the exporter utility for the StrMatch type constraint. Lowkey iconic, highkey useful πŸ’…


✨ SYNOPSIS ✨

use Types::Standard -types;

# Normal way to validate a string against a regular expression.
#
StrMatch->of( qr/.../ )->assert_valid( "foo" );

use Types::Standard::StrMatch Identifier => { re => qr/.../ },

# Exported shortcut
#
assert_Identifier "foo";

πŸ¦‹ STATUS πŸ¦‹

Real talk: this module is not covered by the Type-Tiny stability policy. So don't come for it with stability expectations, okay? 😌


πŸŽ€ DESCRIPTION πŸŽ€

This is mostly internal code, but it can also act as an exporter utility. It's giving "backstage pass but make it Perl" energy 🫢

🌈 Exports 🌈

Types::Standard::ScalarRef can be used experimentally as an exporter β€” that's what the docs say, and I'm repeating it exactly, no edits, no cap.

use Types::Standard::StrMatch Identifier => { re => qr/.../ };

This will export the following functions into your namespace:

  • Identifier
  • is_Identifier( $value )
  • assert_Identifier( $value )
  • to_Identifier( $value )

Multiple types can be exported at once:

use Types::Standard -types;
use Types::Standard::StrMatch (
  Identifier  => { re => qr/.../ },
  Url         => { re => qr/.../ },
       Email       => { re => qr/.../ },
);

assert_Email 'tobyink@example.net';   # should not die

It's possible to further constrain the string using where:

use Types::Standard::StrMatch MyThing => { re => qr/.../, where => sub { ... } };

πŸ’€ BUGS πŸ’€

Please report any bugs to <https://github.com/tobyink/p5-type-tiny/issues>. Do it for the plot, bestie πŸ›βœ¨


πŸ‘‘ SEE ALSO πŸ‘‘

Types::Standard.


🌸 AUTHOR 🌸

Toby Inkster <tobyink@cpan.org>.


This software is copyright (c) 2013-2025 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


🚨 DISCLAIMER OF WARRANTIES 🚨

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

Okay that's the whole page, and we're signing off with perl v5.42.2 energy, dated 2026-04-07 β€” bye bestie, stay regex-ready πŸ’…πŸ«ΆπŸ’–

πŸ“¦ where this page comes from