| 1 | package TUI::Validate::Validator; | ||||||||||
| 2 | # ABSTRACT: Abstract base class for validators | ||||||||||
| 3 | |||||||||||
| 4 | 9 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 9 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 9 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 9 | our $VERSION = '2.000002'; | |||||||||
| 9 | 9 | $VERSION =~ tr/_//d; | |||||||||
| 10 | 9 | our $AUTHORITY = 'cpan:BRICKPOOL'; | |||||||||
| 11 | |||||||||||
| 12 | 9 | ▶ | use Exporter 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 9 | our @EXPORT = qw( | |||||||||
| 14 | TValidator | ||||||||||
| 15 | new_TValidator | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | 9 | ▶ | use TUI::toolkit; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 9 | ▶ | use TUI::toolkit::Types qw( :types ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | 9 | ▶ | use TUI::Objects::Object; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | sub TValidator() { __PACKAGE__ } | ||||||||||
| 24 | sub name() { 'TValidator' }; | ||||||||||
| 25 | 1 | ▶ | sub new_TValidator { __PACKAGE__->from(@_) } | ||||||||
|
Subroutine
new_TValidator: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 26 | |||||||||||
| 27 | 9 | extends TObject; | |||||||||
| 28 | |||||||||||
| 29 | # public attributes | ||||||||||
| 30 | 9 | has status => ( is => 'rw', default => 0 ); | |||||||||
| 31 | 9 | has options => ( is => 'rw', default => 0 ); | |||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | sub error { # void () | ||||||||
|
Subroutine
error: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 34 | 0 | state $sig = signature( | |||||||||
| 35 | method => Object, | ||||||||||
| 36 | pos => [], | ||||||||||
| 37 | ); | ||||||||||
| 38 | 0 | $sig->( @_ ); | |||||||||
| 39 | 0 | return; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 1 | ▶ | sub isValidInput { # $bool ($s, $suppressFill) | ||||||||
|
Subroutine
isValidInput: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 43 | 1 | state $sig = signature( | |||||||||
| 44 | method => Object, | ||||||||||
| 45 | pos => [Str, Bool], | ||||||||||
| 46 | ); | ||||||||||
| 47 | 1 | $sig->( @_ ); | |||||||||
| 48 | 1 | return true; | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 2 | ▶ | sub isValid { # $bool ($s) | ||||||||
|
Subroutine
isValid: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 52 | 2 | state $sig = signature( | |||||||||
| 53 | method => Object, | ||||||||||
| 54 | pos => [Str], | ||||||||||
| 55 | ); | ||||||||||
| 56 | 2 | $sig->( @_ ); | |||||||||
| 57 | 2 | return true; | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 1 | ▶ | sub transfer { # $n ($s, $buffer, $flags) | ||||||||
|
Subroutine
transfer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 61 | 1 | state $sig = signature( | |||||||||
| 62 | method => Object, | ||||||||||
| 63 | pos => [Str, Any, PositiveOrZeroInt], | ||||||||||
| 64 | ); | ||||||||||
| 65 | 1 | $sig->( @_ ); | |||||||||
| 66 | 1 | return 0; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 1 | ▶ | sub validate { # $bool ($s) | ||||||||
|
Subroutine
validate: called CC=2 SCAR=7.9
Pod
documented
| |||||||||||
| 70 | 1 | state $sig = signature( | |||||||||
| 71 | method => Object, | ||||||||||
| 72 | pos => [Str], | ||||||||||
| 73 | ); | ||||||||||
| 74 | 1 | my ( $self, $s ) = $sig->( @_ ); | |||||||||
| 75 | 1 | ▶ | if ( !$self->isValid( $s ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 76 | 0 | $self->error(); | |||||||||
| 77 | 0 | return false; | |||||||||
| 78 | } | ||||||||||
| 79 | 1 | return true; | |||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | 9 | 1 | |||||||||
| 83 | |||||||||||
| 84 | __END__ | ||||||||||