File Coverage

blib/lib/WebService/MinFraud/Data/Rx/Type/IPAddress.pm
Criterion Covered Total %
statement 23 24 95.8
branch 1 2 50.0
condition 2 6 33.3
subroutine 9 9 100.0
pod 0 2 0.0
total 35 43 81.4


line stmt bran cond sub pod time code
1             package WebService::MinFraud::Data::Rx::Type::IPAddress;
2              
3 2     2   42 use 5.010;
  2         7  
4              
5 2     2   11 use strict;
  2         4  
  2         64  
6 2     2   48 use warnings;
  2         4  
  2         57  
7 2     2   10 use namespace::autoclean;
  2         4  
  2         13  
8              
9             our $VERSION = '1.010000';
10              
11 2     2   735 use Data::Validate::IP;
  2         38280  
  2         317  
12              
13 2     2   16 use parent 'Data::Rx::CommonType::EasyNew';
  2         5  
  2         12  
14              
15 2     2   1008 use Role::Tiny::With;
  2         5262  
  2         283  
16              
17             with 'WebService::MinFraud::Role::Data::Rx::Type';
18              
19             sub assert_valid {
20 109     109 0 190469 my ( $self, $value ) = @_;
21              
22 109 50 33     764 return 1
      33        
23             if $value
24             && ( Data::Validate::IP::is_ipv4($value)
25             || Data::Validate::IP::is_ipv6($value) );
26              
27 0         0 $self->fail(
28             {
29             error => [qw(type)],
30             message =>
31             'Found value is not an IP address, neither version 4 nor 6.',
32             value => $value,
33             }
34             );
35             }
36              
37             sub type_uri {
38             ## no critic(ValuesAndExpressions::ProhibitCommaSeparatedStatements)
39 57     57 0 970 'tag:maxmind.com,MAXMIND:rx/ip';
40             }
41              
42             1;
43              
44             # ABSTRACT: A type to check for a valid IP address, version 4 or 6
45              
46             __END__
47              
48             =pod
49              
50             =encoding UTF-8
51              
52             =head1 NAME
53              
54             WebService::MinFraud::Data::Rx::Type::IPAddress - A type to check for a valid IP address, version 4 or 6
55              
56             =head1 VERSION
57              
58             version 1.010000
59              
60             =head1 SUPPORT
61              
62             Bugs may be submitted through L<https://github.com/maxmind/minfraud-api-perl/issues>.
63              
64             =head1 AUTHOR
65              
66             Mateu Hunter <mhunter@maxmind.com>
67              
68             =head1 COPYRIGHT AND LICENSE
69              
70             This software is copyright (c) 2015 - 2020 by MaxMind, Inc.
71              
72             This is free software; you can redistribute it and/or modify it under
73             the same terms as the Perl 5 programming language system itself.
74              
75             =cut