| 1 | package Sah::Schema::ean8_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 7 digits of an EAN-8 number (eg. 9638-507)', | ||
| 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]{7}\z', | ||
| 20 | 'prefilters' => ['Str::remove_nondigit'], | ||
| 21 | |||
| 22 | examples => [ | ||
| 23 | {value=>'9638-507', valid=>1, validated_value=>'9638507'}, | ||
| 24 | {value=>'9638-5074', valid=>0, summary=>'Check digit present'}, | ||
| 25 | {value=>'123456', valid=>0, summary=>'Less than 7 digits'}, | ||
| 26 | ], | ||
| 27 | }]; | ||
| 28 | |||
| 29 | 1 | 1; | |
| 30 | # ABSTRACT: The first 7 digits of an EAN-8 number (eg. 9638-507) | ||
| 31 | |||
| 32 | __END__ | ||