| 1 | package Valiemon::Attributes::Pattern; | ||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use parent qw(Valiemon::Attributes); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 3 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 13 | ▶ | sub attr_name { 'pattern' } | ||||||||
|
Subroutine
attr_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 10 | |||||||||||
| 11 | sub is_valid { | ||||||||||
| 12 | 18 | ▶ | my ($class, $context, $schema, $data) = @_; | ||||||||
|
Subroutine
is_valid: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 13 | |||||||||||
| 14 | 18 | ▶ | return 1 unless $context->prims->is_string($data); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | |||||||||||
| 16 | $context->in_attr($class, sub { | ||||||||||
| 17 | 13 | ▶ | my $pattern = $schema->{pattern}; | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||
| 18 | |||||||||||
| 19 | 13 | ▶ | unless ($context->prims->is_string($pattern)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 2 | croak sprintf '`pattern` must be a string at %s', $context->position | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 11 | ▶ | $data =~ /$pattern/ ? 1 : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 13 | }); | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 3 | 1; | |||||||||