| 1 |
NAME |
| 2 |
Types::UUID - type constraints for UUIDs |
| 3 |
|
| 4 |
SYNOPSIS |
| 5 |
package FroobleStick; |
| 6 |
|
| 7 |
use Moo; |
| 8 |
use Types::UUID; |
| 9 |
|
| 10 |
has identifier => ( |
| 11 |
is => 'lazy', |
| 12 |
isa => Uuid, |
| 13 |
coerce => 1, |
| 14 |
builder => Uuid->generator, |
| 15 |
); |
| 16 |
|
| 17 |
DESCRIPTION |
| 18 |
Types::UUID is a type constraint library suitable for use with Moo/Moose |
| 19 |
attributes, Kavorka sub signatures, and so forth. |
| 20 |
|
| 21 |
Type |
| 22 |
Currently the module only provides one type constraint, which is exported |
| 23 |
by default. |
| 24 |
|
| 25 |
`Uuid` |
| 26 |
A valid UUID string, as judged by the `is_uuid_string()` function |
| 27 |
provided by UUID::Tiny. |
| 28 |
|
| 29 |
This constraint has coercions from `Undef` (generates a new UUID), |
| 30 |
`Str` (fixes slightly broken-looking UUIDs, adding missing dashes; |
| 31 |
also accepts base-64-encoded UUIDs) and URI objects using the |
| 32 |
`urn:uuid:` URI scheme. |
| 33 |
|
| 34 |
Methods |
| 35 |
The `Uuid` type constraint is actually blessed into a subclass of |
| 36 |
Type::Tiny, and provides an aditional method: |
| 37 |
|
| 38 |
`Uuid->generate` |
| 39 |
Generates a new UUID. `Uuid->coerce(undef)` would also work, but looks |
| 40 |
a little odd. |
| 41 |
|
| 42 |
`Uuid->generator` |
| 43 |
Returns a coderef which generates a new UUID. For an example usage, |
| 44 |
see the "SYNOPSIS". |
| 45 |
|
| 46 |
BUGS |
| 47 |
Please report any bugs to |
| 48 |
<http://rt.cpan.org/Dist/Display.html?Queue=Types-UUID>. |
| 49 |
|
| 50 |
SEE ALSO |
| 51 |
Type::Tiny::Manual, UUID::Tiny. |
| 52 |
|
| 53 |
AUTHOR |
| 54 |
Toby Inkster <[email protected]>. |
| 55 |
|
| 56 |
COPYRIGHT AND LICENCE |
| 57 |
This software is copyright (c) 2014 by Toby Inkster. |
| 58 |
|
| 59 |
This is free software; you can redistribute it and/or modify it under the |
| 60 |
same terms as the Perl 5 programming language system itself. |
| 61 |
|
| 62 |
DISCLAIMER OF WARRANTIES |
| 63 |
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
| 64 |
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
| 65 |
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 66 |
|