« blib/lib/JMAP/Validation/Tests/Address.pm
↑ Summary
blib/lib/JMAP/Validation/Tests/ContactGroup.pm »
| 1 | package JMAP::Validation::Tests::String; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 11 | ▶ | use DateTime; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 11 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use JMAP::Validation::Tests::Array; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # data types {{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | sub is_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 120 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_string: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 120 | ▶ | return (ref($value) || '') eq 'JSON::Typist::String'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
ref $value || ''
MC/DC0%0/1
ref $value || ''
ref $value
Truth table50%1/2
A
A= ref $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # }}} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # restrictions {{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | sub has_at_least_one_character { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_at_least_one_character: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | return length($value) >= 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | sub has_at_most_256_bytes { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_at_most_256_bytes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | return length(Encode::encode_utf8($value)) <= 256; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | sub has_no_leading_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_no_leading_hash: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | return $value !~ /^#/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | sub is_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_id: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | is_string($value) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
is_string($value) && has_at_least_one_character($value) && has_at_most_256_bytes($value) && has_no_leading_hash($value)
is_string($value) and has_at_least_one_character($value) and has_at_most_256_bytes($value)
is_string($value) and has_at_least_one_character($value)
MC/DC0%0/4
is_string($value) && has_at_least_one_character($value) && has_at_most_256_bytes($value) && has_no_leading_hash($value)
is_string($value)
has_at_least_one_character($value)
has_at_most_256_bytes($value)
has_no_leading_hash($value)
Truth table0%0/5
A and B and C && D
A= is_string($value)B= has_at_least_one_character($value)C= has_at_most_256_bytes($value)D= has_no_leading_hash($value)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | && has_at_least_one_character($value) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | && has_at_most_256_bytes($value) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | && has_no_leading_hash($value); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | sub is_array_of_ids { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_array_of_ids: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | return unless JMAP::Validation::Tests::Array::is_array($value); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | foreach my $id (@{$value}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | return unless is_id($id); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | sub is_date { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_date: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | return is_string($value); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | return unless $value =~ m{^(\d\d\d\d)-(\d\d)-(\d\d)$}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | return unless eval { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | DateTime->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | year => $1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | month => $2, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | day => $3, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # }}} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||