File Coverage

blib/lib/WebService/MinFraud/Data/Rx/Type/DateTime/RFC3339.pm
Criterion Covered Total %
statement 29 30 96.6
branch 3 4 75.0
condition 3 5 60.0
subroutine 10 10 100.0
pod 0 3 0.0
total 45 52 86.5


line stmt bran cond sub pod time code
1             package WebService::MinFraud::Data::Rx::Type::DateTime::RFC3339;
2              
3 2     2   32 use 5.010;
  2         8  
4              
5 2     2   12 use strict;
  2         4  
  2         37  
6 2     2   9 use warnings;
  2         4  
  2         57  
7 2     2   11 use namespace::autoclean;
  2         5  
  2         17  
8              
9             our $VERSION = '1.009001';
10              
11 2     2   162 use Carp ();
  2         15  
  2         42  
12 2     2   886 use DateTime::Format::RFC3339;
  2         820627  
  2         78  
13              
14 2     2   20 use parent 'Data::Rx::CommonType::EasyNew';
  2         5  
  2         20  
15              
16             sub assert_valid {
17 3     3 0 231 my ( $self, $value ) = @_;
18              
19 3 100 66     12 return 1 if $value && eval { $self->{dt}->parse_datetime($value); };
  3         35  
20              
21 1         347 $self->fail(
22             {
23             error => [qw(type)],
24             message => 'Found value is not a RFC3339 datetime',
25             value => $value,
26             }
27             );
28             }
29              
30             sub guts_from_arg {
31 40     40 0 18656 my ( $class, $arg ) = @_;
32 40   50     138 $arg ||= {};
33              
34 40 50       144 if ( my @unexpected = keys %$arg ) {
35 0         0 Carp::croak sprintf 'Unknown arguments %s in constructing %s',
36             ( join ',' => @unexpected ), $class->type_uri;
37             }
38              
39 40         359 return { dt => DateTime::Format::RFC3339->new, };
40             }
41              
42             sub type_uri {
43             ## no critic(ValuesAndExpressions::ProhibitCommaSeparatedStatements)
44 40     40 0 847 'tag:maxmind.com,MAXMIND:rx/datetime/rfc3339';
45             }
46              
47             1;
48              
49             # ABSTRACT: A type to check if a string parses as a RFC3339 datetime
50              
51             __END__
52              
53             =pod
54              
55             =encoding UTF-8
56              
57             =head1 NAME
58              
59             WebService::MinFraud::Data::Rx::Type::DateTime::RFC3339 - A type to check if a string parses as a RFC3339 datetime
60              
61             =head1 VERSION
62              
63             version 1.009001
64              
65             =head1 SUPPORT
66              
67             Bugs may be submitted through L<https://github.com/maxmind/minfraud-api-perl/issues>.
68              
69             =head1 AUTHOR
70              
71             Mateu Hunter <mhunter@maxmind.com>
72              
73             =head1 COPYRIGHT AND LICENSE
74              
75             This software is copyright (c) 2015 - 2019 by MaxMind, Inc.
76              
77             This is free software; you can redistribute it and/or modify it under
78             the same terms as the Perl 5 programming language system itself.
79              
80             =cut