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         7  
4              
5 2     2   10 use strict;
  2         4  
  2         51  
6 2     2   11 use warnings;
  2         5  
  2         42  
7 2     2   10 use namespace::autoclean;
  2         3  
  2         11  
8              
9             our $VERSION = '1.010000';
10              
11 2     2   196 use Carp ();
  2         4  
  2         53  
12 2     2   863 use DateTime::Format::RFC3339;
  2         864587  
  2         69  
13              
14 2     2   17 use parent 'Data::Rx::CommonType::EasyNew';
  2         5  
  2         18  
15              
16             sub assert_valid {
17 3     3 0 621 my ( $self, $value ) = @_;
18              
19 3 100 66     14 return 1 if $value && eval { $self->{dt}->parse_datetime($value); };
  3         20  
20              
21 1         345 $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 42     42 0 10105 my ( $class, $arg ) = @_;
32 42   50     143 $arg ||= {};
33              
34 42 50       162 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 42         457 return { dt => DateTime::Format::RFC3339->new, };
40             }
41              
42             sub type_uri {
43             ## no critic(ValuesAndExpressions::ProhibitCommaSeparatedStatements)
44 42     42 0 831 '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.010000
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 - 2020 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