line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Member names validation utility |
2
|
|
|
|
|
|
|
package PONAPI::Utils::Names; |
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
20461
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
115
|
|
5
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
132
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
705
|
use parent qw< Exporter >; |
|
4
|
|
|
|
|
301
|
|
|
4
|
|
|
|
|
26
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw< check_name >; |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
3945
|
my $qr_edge = qr/[a-zA-Z0-9\P{ASCII}]/; |
|
4
|
|
|
|
|
44
|
|
|
4
|
|
|
|
|
54
|
|
11
|
|
|
|
|
|
|
my $qr_mid = qr/[a-zA-Z0-9\P{ASCII}_\ -]/; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub check_name { |
14
|
21
|
|
|
21
|
0
|
1957
|
my $name = shift; |
15
|
|
|
|
|
|
|
|
16
|
21
|
100
|
|
|
|
60
|
return if ref($name); |
17
|
20
|
100
|
|
|
|
57
|
return if length($name) == 0; |
18
|
|
|
|
|
|
|
|
19
|
19
|
100
|
|
|
|
81
|
return $name =~ /\A $qr_edge \z/x if length($name) == 1; |
20
|
18
|
100
|
|
|
|
90
|
return $name =~ /\A $qr_edge $qr_edge \z/x if length($name) == 2; |
21
|
17
|
|
|
|
|
330
|
return $name =~ /\A $qr_edge $qr_mid+ $qr_edge \z/x; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
__END__ |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=pod |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=encoding UTF-8 |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
PONAPI::Utils::Names - Member names validation utility |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 VERSION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
version 0.002006 |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 SYNOPSIS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
use PONAPI::Utils::Names 'check_name'; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
check_name('a'); # Valid |
45
|
|
|
|
|
|
|
check_name('a-'); # Invalid |
46
|
|
|
|
|
|
|
check_name('-a'); # Invalid |
47
|
|
|
|
|
|
|
check_name('a-b'); # Valid |
48
|
|
|
|
|
|
|
check_name('a b'); # Valid |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 DESCRIPTION |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This module implements the L<member name restrictions|http://jsonapi.org/format/#document-member-names> |
53
|
|
|
|
|
|
|
from the {json:api} specification; it can be used by repositories |
54
|
|
|
|
|
|
|
to implement strict member names, if desired. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 AUTHORS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=over 4 |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item * |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Mickey Nasriachi <mickey@cpan.org> |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item * |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Stevan Little <stevan@cpan.org> |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item * |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Brian Fraser <hugmeir@cpan.org> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=back |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Mickey Nasriachi, Stevan Little, Brian Fraser. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
79
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |