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 the is_uuid_string() function provided by UUID::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 the SYNOPSIS up 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::Manual
  • UUID::Tiny

🫢 AUTHOR 🫢

Toby Inkster <tobyink@cpan.org>. πŸ’–


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