| 1 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::Constraint::Length; | ||||||||||||||||||||||||||||
| 4 | 6 | $HTML::FormFu::Constraint::Length::VERSION = '2.06'; | |||||||||||||||||||||||||||
| 5 | # ABSTRACT: Min/Max Length String Constraint | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use MooseX::Attribute::Chained; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use MooseX::Aliases; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 6 | extends 'HTML::FormFu::Constraint'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 6 | has minimum => ( | |||||||||||||||||||||||||||
| 14 | is => 'rw', | ||||||||||||||||||||||||||||
| 15 | alias => 'min', | ||||||||||||||||||||||||||||
| 16 | traits => ['Chained'], | ||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 6 | has maximum => ( | |||||||||||||||||||||||||||
| 20 | is => 'rw', | ||||||||||||||||||||||||||||
| 21 | alias => 'max', | ||||||||||||||||||||||||||||
| 22 | traits => ['Chained'], | ||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | sub constrain_value { | ||||||||||||||||||||||||||||
| 26 | 13 | ▶ | my ( $self, $value ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
constrain_value: called CC=7 SCAR=19.7
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 13 | ▶ | return 1 if !defined $value || $value eq ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $value or $value eq ""
MC/DC0%0/2
not defined $value or $value eq ""
not defined $value
$value eq ""
Truth table33%1/3
not(A) or B
A= not defined $valueB= $value eq ""
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 13 | ▶ | if ( defined( my $min = $self->minimum ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 9 | ▶ | return 0 if length $value < $min; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 10 | ▶ | if ( defined( my $max = $self->maximum ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 7 | ▶ | return 0 if length $value > $max; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 8 | return 1; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | sub _localize_args { | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_localize_args: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | return $self->min, $self->max; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 6 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 6 | 1; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =pod | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =head1 NAME | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | HTML::FormFu::Constraint::Length - Min/Max Length String Constraint | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =head1 VERSION | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | version 2.06 | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | Checks the input value meets both a minimum and maximum length. | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | This constraint doesn't honour the C<not()> value. | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =head1 METHODS | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =head2 minimum | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =head2 min | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | The minimum input string length. | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | L</min> is an alias for L</minimum>. | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =head2 maximum | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =head2 max | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | The maximum input string length. | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | L</max> is an alias for L</maximum>. | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | Is a sub-class of, and inherits methods from L<HTML::FormFu::Constraint> | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | L<HTML::FormFu> | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | Carl Franks C<cfranks@cpan.org> | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | This library is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 102 | the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | Carl Franks <cpan@fireartist.com> | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | This software is copyright (c) 2018 by Carl Franks. | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 113 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | =cut | ||||||||||||||||||||||||||||