| 1 | 403 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | |||||||||||
| 3 | package HTML::FormFu::Role::ContainsElementsSharedWithField; | ||||||||||
| 4 | 403 | $HTML::FormFu::Role::ContainsElementsSharedWithField::VERSION = '2.06'; | |||||||||
| 5 | 403 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 403 | use HTML::FormFu::Util qw( | |||||||||
| 8 | require_class | ||||||||||
| 9 | _merge_hashes | ||||||||||
| 10 | 403 | ▶ | ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 403 | ▶ | use Carp qw( croak ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | sub get_error { | ||||||||||
| 14 | 7 | ▶ | my $self = shift; | ||||||||
|
Subroutine
get_error: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 15 | |||||||||||
| 16 | 7 | ▶ | return if !$self->form->submitted; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | |||||||||||
| 18 | 7 | my $c = $self->get_errors(@_); | |||||||||
| 19 | |||||||||||
| 20 | 7 | ▶ | return @$c ? $c->[0] : (); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | sub _require_constraint { | ||||||||||
| 24 | 268 | ▶ | my ( $self, $type, $arg ) = @_; | ||||||||
|
Subroutine
_require_constraint: called CC=6 SCAR=18.0
| |||||||||||
| 25 | |||||||||||
| 26 | 268 | ▶ | croak 'required arguments: $self, $type, \%options' if @_ != 3; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | |||||||||||
| 28 | 268 | eval { my %x = %$arg }; | |||||||||
| 29 | 268 | ▶ | croak "options argument must be hash-ref" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | |||||||||||
| 31 | 268 | my $abs = $type =~ s/^\+//; | |||||||||
| 32 | 268 | my $not = 0; | |||||||||
| 33 | |||||||||||
| 34 | 268 | ▶ | if ( $type =~ /^Not_(\w+)$/i ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 4 | $type = $1; | |||||||||
| 36 | 4 | $not = 1; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 268 | my $class = $type; | |||||||||
| 40 | |||||||||||
| 41 | 268 | ▶ | if ( !$abs ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 268 | $class = "HTML::FormFu::Constraint::$class"; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 268 | $type =~ s/^\+//; | |||||||||
| 46 | |||||||||||
| 47 | 268 | require_class($class); | |||||||||
| 48 | |||||||||||
| 49 | 268 | my $constraint = $class->new( | |||||||||
| 50 | { type => $type, | ||||||||||
| 51 | not => $not, | ||||||||||
| 52 | parent => $self, | ||||||||||
| 53 | } ); | ||||||||||
| 54 | |||||||||||
| 55 | # handle default_args | ||||||||||
| 56 | 268 | my $parent = $self->parent; | |||||||||
| 57 | |||||||||||
| 58 | 268 | ▶ | if ( exists $parent->default_args->{constraints}{$type} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 1 | $arg = _merge_hashes( $parent->default_args->{constraints}{$type}, $arg, | |||||||||
| 60 | ); | ||||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 268 | $constraint->populate($arg); | |||||||||
| 64 | |||||||||||
| 65 | 268 | return $constraint; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 403 | 1; | |||||||||
| 69 | |||||||||||
| 70 | __END__ | ||||||||||
| 71 | |||||||||||
| 72 | =pod | ||||||||||
| 73 | |||||||||||
| 74 | =encoding UTF-8 | ||||||||||
| 75 | |||||||||||
| 76 | =head1 NAME | ||||||||||
| 77 | |||||||||||
| 78 | HTML::FormFu::Role::ContainsElementsSharedWithField | ||||||||||
| 79 | |||||||||||
| 80 | =head1 VERSION | ||||||||||
| 81 | |||||||||||
| 82 | version 2.06 | ||||||||||
| 83 | |||||||||||
| 84 | =head1 AUTHOR | ||||||||||
| 85 | |||||||||||
| 86 | Carl Franks <cpan@fireartist.com> | ||||||||||
| 87 | |||||||||||
| 88 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 89 | |||||||||||
| 90 | This software is copyright (c) 2018 by Carl Franks. | ||||||||||
| 91 | |||||||||||
| 92 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 93 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 94 | |||||||||||
| 95 | =cut | ||||||||||