| 1 | package Badger::Data::Facet::Number; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | use Badger::Class | ||||||||||||||||||||||||||||
| 4 | 1 | version => 0.01, | |||||||||||||||||||||||||||
| 5 | base => 'Badger::Data::Facet', | ||||||||||||||||||||||||||||
| 6 | utils => 'numlike', | ||||||||||||||||||||||||||||
| 7 | messages => { | ||||||||||||||||||||||||||||
| 8 | not_number => '%s is not a number (got %s)', | ||||||||||||||||||||||||||||
| 9 | too_small => '%s should be no less than %d (got %d)', | ||||||||||||||||||||||||||||
| 10 | too_large => '%s should be no more than %d (got %d)', | ||||||||||||||||||||||||||||
| 11 | 1 | ▶ | }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | sub validate { | ||||||||||||||||||||||||||||
| 15 | 2 | ▶ | my ($self, $value, $type) = @_; | ||||||||||||||||||||||||||
|
Subroutine
validate: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 2 | ▶ | return numlike $$value | ||||||||||||||||||||||||||
|
Condition75%3/4
&numlike($$value) || $self->invalid_msg('not_number', $type || 'Text', $$value)
$type || 'Text'
MC/DC0%0/2
&numlike($$value) || $self->invalid_msg('not_number', $type || 'Text', $$value)
&numlike($$value)
$self->invalid_msg('not_number', $type || 'Text', $$value)
MC/DC0%0/1
$type || 'Text'
$type
Truth table66%2/3
A || B
A= &numlike($$value)B= $self->invalid_msg('not_number', $type || 'Text', $$value)
Truth table50%1/2
A
A= $type
| |||||||||||||||||||||||||||||
| 18 | || $self->invalid_msg( not_number => $type || 'Text', $$value ); | ||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | 1; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | __END__ | ||||||||||||||||||||||||||||