File Coverage

blib/lib/Data/Format/Validate/URN.pm
Criterion Covered Total %
statement 8 8 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 11 12 91.6


line stmt bran cond sub pod time code
1             package Data::Format::Validate::URN;
2             our $VERSION = q/0.2/;
3              
4 1     1   67816 use Carp;
  1         10  
  1         46  
5 1     1   4 use base 'Exporter';
  1         2  
  1         183  
6              
7             our @EXPORT_OK = qw/
8             looks_like_urn
9             /;
10              
11             our %EXPORT_TAGS = (
12             q/all/ => [qw/
13             looks_like_urn
14             /]
15             );
16              
17             sub looks_like_urn ($) {
18              
19 13     13 0 109 $_ = shift;
20 13         70 /^
21             urn:
22             [A-Z0-9][A-Z0-9-]{0,31}:
23             [-A-Z0-9()+,\\.:=@;\$_!*'%\/?#]+
24             $/ix
25             }
26             1;
27              
28             =pod
29              
30             =encoding utf8
31              
32             =head1 NAME
33              
34             Data::Format::Validate - A URN validating module.
35              
36             =head1 SYNOPSIS
37              
38             Module that validate URN addressess.
39              
40             =head1 Utilities
41              
42             =over 4
43              
44             =item URN
45              
46             use Data::Format::Validate::URN 'looks_like_urn';
47              
48             looks_like_urn 'urn:oid:2.16.840'; # 1
49             looks_like_urn 'urn:ietf:rfc:2648'; # 1
50             looks_like_urn 'urn:issn:0167-6423'; # 1
51             looks_like_urn 'urn:isbn:0451450523'; # 1
52             looks_like_urn 'urn:mpeg:mpeg7:schema:2001'; # 1
53             looks_like_urn 'urn:uci:I001+SBSi-B10000083052'; # 1
54             looks_like_urn 'urn:lex:br:federal:lei:2008-06-19;11705'; # 1
55             looks_like_urn 'urn:isan:0000-0000-9E59-0000-O-0000-0000-2'; # 1
56             looks_like_urn 'urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66'; # 1
57              
58             looks_like_urn 'oid:2.16.840'; # 0
59             looks_like_urn 'This is not a valid URN'; # 0
60             looks_like_urn 'urn:-768hgf-0000-0000-0000'; # 0
61             looks_like_urn 'urn:this-is-a-realy-big-URN-maybe-the-bigest'; # 0
62            
63             =back
64              
65             =head1 CONTRIBUITION
66              
67             This source is on Github:
68              
69             https://github.com/rozcovo/Data-Format-Validate/blob/master/lib/Data/Format/Validate/URN.pm
70              
71             =head1 AUTHOR
72              
73             Created by Israel Batista <>
74              
75             =cut