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