File Coverage

blib/lib/SyForm/ViewFieldRole/Verify.pm
Criterion Covered Total %
statement 12 12 100.0
branch 5 6 83.3
condition n/a
subroutine 5 5 100.0
pod n/a
total 22 23 95.6


line stmt bran cond sub pod time code
1             package SyForm::ViewFieldRole::Verify;
2             BEGIN {
3 3     3   1990 $SyForm::ViewFieldRole::Verify::AUTHORITY = 'cpan:GETTY';
4             }
5             # ABSTRACT: Trait for SyForm fields of SyForm::Results and SyForm::Values attributes
6             $SyForm::ViewFieldRole::Verify::VERSION = '0.103';
7 3     3   21 use Moo::Role;
  3         5  
  3         17  
8              
9             has is_invalid => (
10             is => 'lazy',
11             );
12              
13             sub _build_is_invalid {
14 13     13   358 my ( $self ) = @_;
15 13 100       195 return $self->is_valid ? 0 : 1;
16             }
17              
18             has is_valid => (
19             is => 'lazy',
20             );
21              
22             sub _build_is_valid {
23 13     13   95 my ( $self ) = @_;
24 13         21 my @errors = @{$self->errors};
  13         231  
25 13 100       2675 return scalar @errors > 0 ? 0 : 1;
26             }
27              
28             has errors => (
29             is => 'lazy',
30             );
31              
32             sub _build_errors {
33 13     13   100 my ( $self ) = @_;
34 13 50       193 return $self->results->does('SyForm::ResultsRole::Success')
35             ? $self->results->syccess_result->errors($self->name) : [];
36             }
37              
38             # sub has_original_value {
39             # my ( $self ) = @_;
40             # return $self->has_value;
41             # }
42              
43             # sub original_value {
44             # my ( $self ) = @_;
45             # return $self->results->verify_results->get_original_value($self->name);
46             # }
47              
48             1;
49              
50             __END__
51              
52             =pod
53              
54             =head1 NAME
55              
56             SyForm::ViewFieldRole::Verify - Trait for SyForm fields of SyForm::Results and SyForm::Values attributes
57              
58             =head1 VERSION
59              
60             version 0.103
61              
62             =head1 AUTHOR
63              
64             Torsten Raudssus <torsten@raudss.us>
65              
66             =head1 COPYRIGHT AND LICENSE
67              
68             This software is copyright (c) 2014 by Torsten Raudssus.
69              
70             This is free software; you can redistribute it and/or modify it under
71             the same terms as the Perl 5 programming language system itself.
72              
73             =cut