File Coverage

blib/lib/Sah/Schema/hexstr.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package Sah::Schema::hexstr;
2              
3 1     1   469141 use strict;
  1         3  
  1         256  
4              
5             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
6             our $DATE = '2024-02-06'; # DATE
7             our $DIST = 'Sah-Schemas-Str'; # DIST
8             our $VERSION = '0.018'; # VERSION
9              
10             our $schema = [str => {
11             summary => 'String of bytes in hexadecimal notation, e.g. "ab99" or "CAFE"',
12             prefilters => ['Str::remove_whitespace'],
13             match => qr/\A(?:[0-9A-Fa-f]{2})*\z/,
14              
15             description => <<'_',
16              
17             Whitespace is allowed and will be removed.
18              
19             _
20             examples => [
21             {value=>'', valid=>1},
22             {value=>'a0', valid=>1},
23             {value=>'A0', valid=>1, summary=>'Uppercase digits are allowed, not coerced to lowercase'},
24             {value=>'a0f', valid=>0, summary=>'Odd number of digits (3)'},
25             {value=>'a0ff', valid=>1},
26             {value=>'a0 ff 61', valid=>1, summary=>'Whitespace will be removed', validated_value=>'a0ff61'},
27             {value=>'a0fg', valid=>0, summary=>'Invalid hexdigit (g)'},
28             {value=>'a0ff12345678', valid=>1},
29             ],
30              
31             }];
32              
33             1;
34             # ABSTRACT:
35              
36             __END__