Branch Coverage

blib/lib/Mojolicious/Plugin/FormFieldsFromJSON.pm
Criterion Covered Total %
branch 210 254 82.6


line true false branch
29 1 86 if ($config->{'template_file'})
35 1 86 if (ref $config->{'dir'} eq 'ARRAY') { }
43 86 1 unless $config->{'types'}
56 0 1 if (%configfiles)
66 2 3 unless $file =~ /\.json\z/u
86 1 1 unless ($configs{$file})
98 1 1 if ($params and $params->{'hash'})
110 0 35 unless $file
112 12 23 unless ($configs{$file})
116 0 35 unless $configs{$file}
123 0 35 unless $params_hash
129 0 31 unless $param_values
1 30 @{[] unless $param_values;} > 1 ? :
139 0 35 if ('HASH' ne ref $field)
144 0 35 unless ($field->{'validation'})
148 0 35 if ('HASH' ne ref $field->{'validation'})
158 12 23 if ($field->{'validation'}{'required'}) { }
159 7 5 unless $filters
162 2 10 if (ref $value and 'HASH' eq ref $value)
167 16 7 unless $filters
172 6 48 unless defined $params{$name}
174 7 41 if $rule eq 'required'
175 11 30 if $rule eq 'filters'
184 3 27 if (not $ref) { }
17 10 elsif ($ref eq 'ARRAY') { }
10 0 elsif ($ref eq 'HASH') { }
191 10 0 ref $value->{'args'} ? :
198 0 30 unless (eval { do { $validation->check($method, @params); 1 } })
202 10 20 if ($validation->has_error($name))
208 5 30 if ($validation->has_error($name) and not defined $errors{$name})
222 1 106 unless $self->_load_config_from_file($c, \%configs, $file)
223 0 1 unless $configs{$file} or ref $file
228 104 2 unless $params{'fields'}
232 2 143 if %fields_to_show and not $fields_to_show{$field->{'name'}}
236 143 0 if (length $field_content)
250 0 4 unless $self->_load_config_from_file($c, \%configs, $file)
251 0 0 unless $configs{$file} or ref $file
257 0 4 unless scalar @fields_filtered
269 0 124 unless $file
271 87 1 unless ($configs->{$file} or ref $file)
278 86 5 if -r $_path
281 1 86 unless (defined $path)
290 0 86 unless (eval { do { my $content = 'Mojo::Asset::File'->new('path', $path)->slurp; $configs->{$file} = decode_json($content) } })
295 0 86 if ('ARRAY' ne ref $configs->{$file})
307 0 147 if ('HASH' ne ref $field)
315 3 1 if ($plugin_config->{'alias'} and $plugin_config->{'alias'}{$type})
319 0 147 unless ($valid_types->{$type})
324 24 4 if ($plugin_config->{'global_attributes'} and $type ne 'hidden' and 'HASH' eq ref $plugin_config->{'global_attributes'})
336 6 18 if $field_attr =~ /\Q$global_attr\E/u
338 6 12 length $field_attr ? :
344 2 0 if ($field->{'translate_sublabels'} and $plugin_config->{'translation_method'} and not $field->{'translation_method'})
360 23 124 if ($template and $type ne 'hidden')
364 1 0 if ($plugin_config->{'translate_labels'} and $loc and 'CODE' eq ref $loc)
393 0 8 $from_stash_key ? :
400 8 0 unless $field->{'attributes'}
413 1 32 $from_stash_key ? :
420 27 6 unless $field->{'attributes'}
433 1 37 $from_stash_key ? :
444 0 38 unless $stash_values
3 35 if (scalar @{[] unless $stash_values;} == 0 and defined $c->stash($name))
446 1 2 ref $local_stash ? :
449 1 37 if ($from_stash)
450 0 1 ref $from_stash ? :
454 0 38 unless $stash_values
13 25 if (@{[] unless $stash_values;})
463 7 69 if (keys %{$hashref;})
468 5 33 if ($field_params->{'data'})
474 33 5 unless $field->{'attributes'}
476 4 34 if ($field->{'multiple'})
482 18 20 if (@selected)
484 14 4 $single == 1 ? :
491 13 25 if ($reset)
493 10 3 $single == 1 ? :
503 317 69 unless $field->{$key}
507 25 44 if (not ref $field->{$key}) { }
44 0 elsif ('ARRAY' eq ref $field->{$key}) { }
524 1 38 if ($field->{'data_cb'})
529 1 0 if $sub
533 35 4 if ('ARRAY' eq ref $data) { }
4 0 elsif ('HASH' eq ref $data) { }
553 1 6 if (ref $data->{$key}) { }
561 0 6 if $params{'disabled'}{$key}
562 0 6 if $params{'selected'}{$key}
573 3 1 if (&first(sub { $_ =~ /[^0-9]/u; } , keys %mapping))
580 1 3 $numeric ? :
596 35 58 if ($numeric and $value =~ /[^0-9]/u)
602 5 88 if $params{'disabled'}{$value}
603 22 71 if $params{'selected'}{$value}
612 0 35 $numeric ? :
622 21 4 unless $field->{'attributes'}
625 17 8 ref $data ? :
635 0 25 unless $stash_values
1 24 if (scalar @{[] unless $stash_values;} == 0 and defined $c->stash($name))
637 0 1 ref $local_stash ? :
641 0 25 unless $stash_values
4 21 if (@{[] unless $stash_values;})
651 5 45 if (keys %{$hashref;})
657 6 19 if (@selected)
659 6 0 $single == 1 ? :
667 3 39 if ($select_params{'disabled'}{$radio_value})
671 6 36 if ($select_params{'selected'}{$radio_value})
676 4 38 if ($field->{'show_value'})
681 2 0 if (length $local_label and $field->{'translate_sublabels'} and $loc and 'CODE' eq ref $loc)
685 4 38 if length $local_label
694 2 40 if (defined $field->{'after_element'})
699 4 21 if ($reset)
701 4 0 $single == 1 ? :
713 24 4 unless $field->{'attributes'}
716 15 13 ref $data ? :
726 0 28 unless $stash_values
2 26 if (scalar @{[] unless $stash_values;} == 0 and defined $c->stash($name))
728 1 1 ref $local_stash ? :
732 0 28 unless $stash_values
5 23 if (@{[] unless $stash_values;})
741 6 50 if (keys %{$hashref;})
747 8 20 if (@selected)
749 7 1 $single == 1 ? :
757 3 41 if ($select_params{'disabled'}{$checkbox_value})
761 9 35 if ($select_params{'selected'}{$checkbox_value})
766 4 40 if ($field->{'show_value'})
771 2 0 if (length $local_label and $field->{'translate_sublabels'} and $loc and 'CODE' eq ref $loc)
775 4 40 if length $local_label
784 3 41 if (defined $field->{'after_element'})
789 5 23 if ($reset)
791 4 1 $single == 1 ? :
804 3 5 unless $field->{'attributes'}
815 2 4 unless $field->{'attributes'}