| 1 | package Sah::Schema::unix::groupname; | ||
| 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-11-15'; # DATE | |
| 7 | 1 | our $DIST = 'Sah-SchemaBundle-Unix'; # DIST | |
| 8 | 1 | our $VERSION = '0.022'; # VERSION | |
| 9 | |||
| 10 | 1 | our $schema = [str => { | |
| 11 | summary => 'Unix group name', | ||
| 12 | description => <<'MARKDOWN', | ||
| 13 | |||
| 14 | The checking follows POSIX rules: does not begin with a hyphen and only contains | ||
| 15 | [A-Za-z0-9._-]. | ||
| 16 | |||
| 17 | The above rule allows integers like 1234, which can be confused with GID, so | ||
| 18 | this schema disallows pure integers. | ||
| 19 | |||
| 20 | The maximum length is 32 following libc6's limit. | ||
| 21 | |||
| 22 | Note that this schema does not check whether the group name exists (has record | ||
| 23 | in the user database e.g. `/etc/group`). To do that, use the | ||
| 24 | `unix::groupname::exists` schema. | ||
| 25 | |||
| 26 | MARKDOWN | ||
| 27 | prefilters => ['Unix::convert_gid_to_unix_group'], | ||
| 28 | 'x.completion' => ['unix_group_or_gid'], | ||
| 29 | min_len => 1, | ||
| 30 | max_len => 32, | ||
| 31 | match => qr/(?=\A[A-Za-z0-9._][A-Za-z0-9._-]{0,31}\z)(?=.*[A-Za-z._-])/, | ||
| 32 | |||
| 33 | examples => [ | ||
| 34 | {value=>'', valid=>0}, | ||
| 35 | {value=>'foo', valid=>1}, | ||
| 36 | {value=>'-andy', valid=>0}, | ||
| 37 | {value=>'1234', valid=>0}, | ||
| 38 | {value=>'andy2', valid=>1}, | ||
| 39 | {value=>'an dy', valid=>0}, | ||
| 40 | {value=>'an.dy', valid=>1}, | ||
| 41 | {value=>'a' x 33, valid=>0, summary=>'Too long'}, | ||
| 42 | ], | ||
| 43 | |||
| 44 | }]; | ||
| 45 | |||
| 46 | 1 | 1; | |
| 47 | # ABSTRACT: Unix group name | ||
| 48 | |||
| 49 | __END__ | ||