Data::Validate::UUID - Data Validator to check for well formed UUIDs
use Data::Validate::UUID qw( is_uuid ); my $valid_uuid = '91AE3596-95FA-11E4-AB6C-6CFF01D6B4DB'; my $invalid_uuid = 'INVALID UUID'; if( is_uuid( $valid_uuid ) ) { print 'Looks good to me!'; } if( !is_uuid( $invalid_uuid ) ) { print 'Not a valid UUID!'; }
Data::Validate::UUID optionally exports a single method is_uuid that will check the format of the provided UUID to see if it conforms to RFC 4122. For more information about UUID's and a perl module for generating them please see Data::UUID.
is_uuid( '91AE3596-95FA-11E4-AB6C-6CFF01D6B4DB' ); # returns truthy is_uuid( 'INVALID UUID' ); # returns falsey
is_uuid accepts a scalar and returns a truthy or falsey value based on if the provided value is a valid UUID.
The Regular Expression used in this module comes from DrEinsteinium on the Bukkit forums. This is a link to the thread. I've also seen this Regular Expression posted by Gambol in this stack overflow answer. Hopefully they don't mind me packaging it up for distrubtion.
Special thanks to BrainStorm Incubator for providing development resources and allowing this module to be open soruced.
Robert Stone, drzigman AT cpan DOT org
drzigman AT cpan DOT org
Copyright 2014 Robert Stone
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU Lesser General Public License as published by the Free Software Foundation; or any compatible license.
See http://dev.perl.org/licenses/ for more information.
To install Data::Validate::UUID, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Validate::UUID
CPAN shell
perl -MCPAN -e shell install Data::Validate::UUID
For more information on module installation, please visit the detailed CPAN module installation guide.