MuForm/Field/URL.pm

filter: Statementstmt 100% 16 / 16 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 50.0% 1 / 2 totaltotal 95.8% 23 / 24 SCAR 6.9
CC
2
Cov
100%
validate
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« MuForm/Field/Button.pm ↑ Summary MuForm/Field/Boolean.pm »
1 package Data::MuForm::Field::URL;
2 # ABSTRACT: URL field
3 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 extends 'Data::MuForm::Field::Text';
5 2 ▶use Regexp::Common ('URI');
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 2 has '+html5_input_type' => ( default => 'url' );
9  
10 2 our $class_messages = {
11 'invalid_url' => 'Invalid URL',
12 };
13  
14 sub get_class_messages {
15 1 ▶ my $self = shift;
Subroutine get_class_messages: called CC=1 SCAR=0.0
Pod undocumented
16 return {
17 1 %{ $self->next::method },
18 %$class_messages,
19 }
20 }
21  
22 sub validate {
23 2 ▶ my ($self, $value) = @_;
Subroutine validate: called CC=2 SCAR=6.9
Pod documented
24 2 ▶ unless ( $value =~ qr/^$RE{URI}{HTTP}{-scheme => "https?"}$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($value =~ qr/^$Data::MuForm::Field::URL::RE{"URI"}{"HTTP"}{join $;, "-scheme", "https?"}$/) 1 1 2
25 1 $self->add_error($self->get_message('invalid_url'));
26 }
27 }
28  
29 2 1;
30  
31 __END__
32  
33 =pod
34  
35 =encoding UTF-8
36  
37 =head1 NAME
38  
39 Data::MuForm::Field::URL - URL field
40  
41 =head1 VERSION
42  
43 version 0.04
44  
45 =head1 DESCRIPTION
46  
47 A URL field;
48  
49 =head1 NAME
50  
51 Data::MuForm::Field::URL
52  
53 =head1 AUTHOR
54  
55 Gerda Shank
56  
57 =head1 COPYRIGHT AND LICENSE
58  
59 This software is copyright (c) 2017 by Gerda Shank.
60  
61 This is free software; you can redistribute it and/or modify it under
62 the same terms as the Perl 5 programming language system itself.
63  
64 =cut
« MuForm/Field/Button.pm ↑ Summary MuForm/Field/Boolean.pm »