Sah/Schema/ean8.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
« Sah/Schema/ean13_without_check_digit.pm ↑ Summary Sah/Schema/ean8_without_check_digit.pm »
1 package Sah::Schema::ean8;
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-8 number',
12 description => <<'_',
13  
14 Nondigits [^0-9] will be removed during coercion.
15  
16 Checksum digit must be valid.
17  
18 Length must be 8 digits.
19  
20 _
21 match => '\A[0-9]{8}\z',
22 'x.perl.coerce_rules' => ['From_str::to_ean8'],
23  
24 examples => [
25 {value=>'9638-5074', valid=>1, validated_value=>'96385074'},
26 {value=>'12345678', valid=>0, summary=>'Invalid checkdigit'},
27 {value=>'1234567', valid=>0, summary=>'Less than 8 digits'},
28 {value=>'123456789', valid=>0, summary=>'More than 8 digits'},
29 ],
30 }];
31  
32 1 1;
33 # ABSTRACT: EAN-8 number
34  
35 __END__
« Sah/Schema/ean13_without_check_digit.pm ↑ Summary Sah/Schema/ean8_without_check_digit.pm »