File Coverage

blib/lib/Specio/Library/String.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


line stmt bran cond sub pod time code
1             package Specio::Library::String;
2              
3 12     12   72 use strict;
  12         26  
  12         293  
4 12     12   54 use warnings;
  12         29  
  12         410  
5              
6             our $VERSION = '0.46';
7              
8 12     12   60 use parent 'Specio::Exporter';
  12         20  
  12         51  
9              
10 12     12   626 use Specio::Declare;
  12         23  
  12         72  
11 12     12   80 use Specio::Library::Builtins;
  12         32  
  12         88  
12              
13             declare(
14             'NonEmptySimpleStr',
15             parent => t('Str'),
16             inline => sub {
17             return
18             sprintf(
19             <<'EOF', $_[0]->parent->inline_check( $_[1] ), ( $_[1] ) x 3 );
20             (
21             %s
22             &&
23             length %s > 0
24             &&
25             length %s <= 255
26             &&
27             %s !~ /[\n\r\x{2028}\x{2029}]/
28             )
29             EOF
30             },
31             );
32              
33             declare(
34             'NonEmptyStr',
35             parent => t('Str'),
36             inline => sub {
37             return
38             sprintf( <<'EOF', $_[0]->parent->inline_check( $_[1] ), $_[1] );
39             (
40             %s
41             &&
42             length %s
43             )
44             EOF
45             },
46             );
47              
48             declare(
49             'SimpleStr',
50             parent => t('Str'),
51             inline => sub {
52             return
53             sprintf(
54             <<'EOF', $_[0]->parent->inline_check( $_[1] ), ( $_[1] ) x 2 );
55             (
56             %s
57             &&
58             length %s <= 255
59             &&
60             %s !~ /[\n\r\x{2028}\x{2029}]/
61             )
62             EOF
63             },
64             );
65              
66             1;
67              
68             # ABSTRACT: Implements type constraint objects for some common string types
69              
70             __END__
71              
72             =pod
73              
74             =encoding UTF-8
75              
76             =head1 NAME
77              
78             Specio::Library::String - Implements type constraint objects for some common string types
79              
80             =head1 VERSION
81              
82             version 0.46
83              
84             =head1 DESCRIPTION
85              
86             This library provides some additional string types for common cases.
87              
88             =head2 NonEmptyStr
89              
90             A string which has at least one character.
91              
92             =head2 SimpleStr
93              
94             A string that is 255 characters or less with no vertical whitespace
95             characters.
96              
97             =head2 NonEmptySimpleStr
98              
99             A non-empty string that is 255 characters or less with no vertical whitespace
100             characters.
101              
102             =head1 SUPPORT
103              
104             Bugs may be submitted at L<https://github.com/houseabsolute/Specio/issues>.
105              
106             I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>.
107              
108             =head1 SOURCE
109              
110             The source code repository for Specio can be found at L<https://github.com/houseabsolute/Specio>.
111              
112             =head1 AUTHOR
113              
114             Dave Rolsky <autarch@urth.org>
115              
116             =head1 COPYRIGHT AND LICENSE
117              
118             This software is Copyright (c) 2012 - 2020 by Dave Rolsky.
119              
120             This is free software, licensed under:
121              
122             The Artistic License 2.0 (GPL Compatible)
123              
124             The full text of the license can be found in the
125             F<LICENSE> file included with this distribution.
126              
127             =cut