| 1 | package Sah::Schema::ean13_without_check_digit; | ||
| 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 => 'The first 12 digits of an EAN-13 number (eg. 5-901234-12345)', | ||
| 12 | description => <<'_', | ||
| 13 | |||
| 14 | Nondigits [^0-9] will be removed during coercion. | ||
| 15 | |||
| 16 | Length must be 7 digits. | ||
| 17 | |||
| 18 | _ | ||
| 19 | match => '\A[0-9]{12}\z', | ||
| 20 | 'prefilters' => ['Str::remove_nondigit'], | ||
| 21 | |||
| 22 | examples => [ | ||
| 23 | {value=>'5-901234-12345', valid=>1, validated_value=>'590123412345'}, | ||
| 24 | {value=>'5-901234-123457', valid=>0, summary=>'Check digit present'}, | ||
| 25 | {value=>'12345678901', valid=>0, summary=>'Less than 12 digits'}, | ||
| 26 | ], | ||
| 27 | }]; | ||
| 28 | |||
| 29 | 1 | 1; | |
| 30 | # ABSTRACT: The first 12 digits of an EAN-13 number (eg. 5-901234-12345) | ||
| 31 | |||
| 32 | __END__ | ||