Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
69 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use strict; | ||
use warnings; | ||
package MetaCPAN::Client::Types; | ||
# ABSTRACT: type checking helper class | ||
|
||
use Type::Tiny (); | ||
use Types::Standard (); | ||
use Ref::Util qw< is_ref >; | ||
|
||
use parent 'Exporter'; | ||
our @EXPORT_OK = qw< Str Int Time ArrayRef HashRef >; | ||
|
||
sub Str { Types::Standard::Str } | ||
sub Int { Types::Standard::Int } | ||
sub ArrayRef { Types::Standard::ArrayRef } | ||
sub HashRef { Types::Standard::HashRef } | ||
|
||
sub Time { | ||
return Type::Tiny->new( | ||
name => "Time", | ||
constraint => sub { !is_ref($_) and /^[1-9][0-9]*(?:s|m|h)$/ }, | ||
message => sub { "$_ is not in time format (e.g. '5m')" }, | ||
); | ||
} | ||
1; | ||
__END__ | ||
=head1 METHODS | ||
=head2 ArrayRef | ||
=head2 HashRef | ||
=head2 Int | ||
=head2 Str | ||
=head2 Time |