Sah/Schema/hexstr.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 100% 10 / 10 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
CRAP 1.0
« Data/Sah/Filter/perl/Str/maybe_convert_to_re.pm ↑ Summary Sah/Schema/latin_alpha.pm »
1 package Sah::Schema::hexstr;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
6 1 our $DATE = '2024-02-06'; # DATE
7 1 our $DIST = 'Sah-Schemas-Str'; # DIST
8 1 our $VERSION = '0.018'; # VERSION
9  
10 1 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 1;
34 # ABSTRACT:
35  
36 __END__
« Data/Sah/Filter/perl/Str/maybe_convert_to_re.pm ↑ Summary Sah/Schema/latin_alpha.pm »