Sah/Schema/ean13.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 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
CRAP 1.0
« Data/Sah/Coerce/perl/To_str/From_str/to_ean8.pm ↑ Summary Sah/Schema/ean13_without_check_digit.pm »
1 package Sah::Schema::ean13;
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 = '2023-01-27'; # DATE
7 1 our $DIST = 'Sah-Schemas-EAN'; # DIST
8 1 our $VERSION = '0.008'; # VERSION
9  
10 1 our $schema = [str => {
11 summary => 'EAN-13 number (e.g. 5-901234-123457)',
12 description => <<'_',
13  
14 Nondigits [^0-9] will be removed during coercion.
15  
16 Checksum digit must be valid.
17  
18 Length must be 13 digits.
19  
20 _
21 match => '\A[0-9]{13}\z',
22 'x.perl.coerce_rules' => ['From_str::to_ean13'],
23  
24 examples => [
25 {value=>'5-901234-123457', valid=>1, validated_value=>'5901234123457'},
26 {value=>'123-4567890-123', valid=>0, summary=>'Invalid checkdigit'},
27 {value=>'1234567890', valid=>0, summary=>'Less than 13 digits'},
28 {value=>'12345678901234', valid=>0, summary=>'More than 13 digits'},
29 ],
30 }];
31  
32 1 1;
33 # ABSTRACT: EAN-13 number (e.g. 5-901234-123457)
34  
35 __END__
« Data/Sah/Coerce/perl/To_str/From_str/to_ean8.pm ↑ Summary Sah/Schema/ean13_without_check_digit.pm »