| 1 | package Syccess::Validator::IsNumber; | ||||||||||
| 2 | 2 | our $AUTHORITY = 'cpan:GETTY'; | |||||||||
| 3 | # ABSTRACT: A validator to check if value is a number | ||||||||||
| 4 | 2 | $Syccess::Validator::IsNumber::VERSION = '0.104'; | |||||||||
| 5 | 2 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use Scalar::Util qw( looks_like_number ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 2 | with qw( | |||||||||
| 9 | Syccess::ValidatorSimple | ||||||||||
| 10 | ); | ||||||||||
| 11 | |||||||||||
| 12 | 2 | has message => ( | |||||||||
| 13 | is => 'lazy', | ||||||||||
| 14 | ); | ||||||||||
| 15 | |||||||||||
| 16 | 1 | ▶ | sub _build_message { | ||||||||
|
Subroutine
_build_message: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 1 | return '%s must be a number.'; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 3 | ▶ | sub validator { | ||||||||
|
Subroutine
validator: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 21 | 3 | my ( $self, $value ) = @_; | |||||||||
| 22 | 3 | ▶ | return $self->message unless looks_like_number($value); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 1 | return; | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 2 | 1; | |||||||||
| 27 | |||||||||||
| 28 | __END__ | ||||||||||