File Coverage

blib/lib/Data/MuForm/Field/URL.pm
Criterion Covered Total %
statement 12 12 100.0
branch 2 2 100.0
condition n/a
subroutine 4 4 100.0
pod 1 2 50.0
total 19 20 95.0


line stmt bran cond sub pod time code
1             package Data::MuForm::Field::URL;
2             # ABSTRACT: URL field
3 1     1   471 use Moo;
  1         1  
  1         5  
4             extends 'Data::MuForm::Field::Text';
5 1     1   643 use Regexp::Common ('URI');
  1         1780  
  1         3  
6              
7              
8             our $class_messages = {
9             'invalid_url' => 'Invalid URL',
10             };
11              
12             sub get_class_messages {
13 1     1 0 1 my $self = shift;
14             return {
15 1         1 %{ $self->next::method },
  1         6  
16             %$class_messages,
17             }
18             }
19              
20             sub validate {
21 2     2 1 4 my ($self, $value) = @_;
22 2 100       11 unless ( $value =~ qr/^$RE{URI}{HTTP}{-scheme => "https?"}$/ ) {
23 1         294 $self->add_error($self->get_message('invalid_url'));
24             }
25             }
26              
27             1;
28              
29             __END__
30              
31             =pod
32              
33             =encoding UTF-8
34              
35             =head1 NAME
36              
37             Data::MuForm::Field::URL - URL field
38              
39             =head1 VERSION
40              
41             version 0.03
42              
43             =head1 DESCRIPTION
44              
45             A URL field;
46              
47             =head1 NAME
48              
49             Data::MuForm::Field::URL
50              
51             =head1 AUTHOR
52              
53             Gerda Shank
54              
55             =head1 COPYRIGHT AND LICENSE
56              
57             This software is copyright (c) 2017 by Gerda Shank.
58              
59             This is free software; you can redistribute it and/or modify it under
60             the same terms as the Perl 5 programming language system itself.
61              
62             =cut