line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Mattermost::V4::API::Role::RequireID; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
8
|
|
|
8
|
|
4701
|
use Moo::Role; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
60
|
|
6
|
8
|
|
|
8
|
|
4579
|
use Types::Standard 'RegexpRef'; |
|
8
|
|
|
|
|
66610
|
|
|
8
|
|
|
|
|
60
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
requires 'error_return'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has id_validation_regexp => (is => 'ro', isa => RegexpRef, default => sub { qr{(?i)^[a-z0-9\-]+$} }); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub validate_id { |
17
|
8
|
|
|
8
|
1
|
990
|
my $self = shift; |
18
|
8
|
|
|
|
|
19
|
my $next = shift; |
19
|
8
|
|
|
|
|
18
|
my $id = shift; |
20
|
|
|
|
|
|
|
|
21
|
8
|
100
|
|
|
|
39
|
if ($self->validate_id_no_next($id)) { |
22
|
5
|
|
|
|
|
33
|
return $self->$next($id, @_); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
33
|
return $self->error_return('Invalid or missing ID parameter'); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub validate_id_no_next { |
29
|
8
|
|
|
8
|
1
|
19
|
my $self = shift; |
30
|
8
|
|
|
|
|
18
|
my $id = shift; |
31
|
|
|
|
|
|
|
|
32
|
8
|
100
|
100
|
|
|
116
|
return ($id && $id =~ $self->id_validation_regexp) ? 1 : 0; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=pod |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=encoding UTF-8 |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 NAME |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
WebService::Mattermost::V4::API::Role::RequireID - ID validation. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 VERSION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
version 0.26 |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 DESCRIPTION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Validate that the first parameter passed to a subroutine is a valid UUID for |
56
|
|
|
|
|
|
|
Mattermost. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 METHODS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=over 4 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item C<validate_id()> |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Validate the ID and run the next subroutine. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item C<validate_id_no_next()> |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Validate the ID but do not run the next subroutine. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=back |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 ATTRIBUTES |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=over 4 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item C<id_validation_regexp> |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Basic UUID matching regular expression. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=back |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Mike Jones <mike@netsplit.org.uk> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Mike Jones. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This is free software, licensed under: |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
The MIT (X11) License |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|