Types::UUID(3pm)
π Types::UUID β the whole vibe π
okay so bestie, you know how sometimes you just need a UUID and you want your type constraints to handle it? That's this. It's Types::UUID, a User Contributed Perl Documentation page, and it is lowkey the most useful little module you'll meet today. π¦
β¨ NAME β¨
Types::UUID β type constraints for UUIDs. that's it. that's the whole name. iconic. π
πΈ SYNOPSIS πΈ
here's the moment you've been waiting for, the main character entrance:
package FroobleStick;
use Moo;
use Types::UUID;
has identifier => (
is => 'lazy',
isa => Uuid,
coerce => 1,
builder => Uuid->generator,
);
see how clean that is?? builder => Uuid->generator is doing SO much heavy lifting and saying nothing about it. that's the energy. π
π DESCRIPTION π
Types::UUID is a type constraint library β it's built to vibe with Moo/Moose attributes, Kavorka sub signatures, and honestly whatever else you wanna throw it at.
π Type π
rn the module only ships one type constraint, and it's exported by default (so you get it for free, no extra work, love that for you).
Uuidβ a valid UUID string, as judged by theis_uuid_string()function provided byUUID::Tiny. β¨
this constraint has coercions from:
Undefβ generates a new UUID (surprise! a fresh one just for you π)Strβ fixes slightly broken-looking UUIDs by adding the missing dashes; it also accepts base-64-encoded UUIDs π- URI objects using the
urn:uuid:URI scheme π
π§ Methods π§
plot twist: the Uuid type constraint is actually blessed into a subclass of Type::Tiny, and it comes with an aditional method (yes, that's the spelling in the original, we don't gatekeep typos here π):
Uuid->generateβ generates a new UUID. and yeah,Uuid->coerce(undef)would also work, but ngl it looks a little odd. πUuid->generatorβ returns a coderef which generates a new UUID. for an example usage, go peek at theSYNOPSISup there β¬οΈ
π BUGS π
found a bug? please report it, bestie, we wanna know:
<http://rt.cpan.org/Dist/Display.html?Queue=Types-UUID>
π SEE ALSO π
go read these too, they're part of the friend group:
Type::Tiny::ManualUUID::Tiny
π«Ά AUTHOR π«Ά
Toby Inkster <tobyink@cpan.org>. π
π COPYRIGHT AND LICENCE π
This software is copyright (c) 2014 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. slay. β
π 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.
fr fr, no promises, no cap, read it exactly as written. π¨
and that's the whole page bestie!! π it's Types::UUID, from the perl v5.34.0 era, dated 2022-06-28, and it's giving "small module, big heart". go make some UUIDs. π
β¨π¦
π¦ where this page comes from
- debian bookworm: libtypes-uuid-perl 0.004-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtypes-uuid-perl 0.004-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms