Branch Coverage

blib/lib/Mojolicious/Plugin/FormFieldsFromJSON.pm
Criterion Covered Total %
branch 201 244 82.3


line true false branch
32 1 84 if ($config->{'template_file'})
38 1 84 if (ref $config->{'dir'} eq 'ARRAY') { }
46 84 1 unless $config->{'types'}
59 0 1 if (%configfiles)
69 2 3 unless $file =~ /\.json\z/u
89 1 1 unless ($configs{$file})
101 1 1 if ($params and $params->{'hash'})
113 0 23 unless $file
115 10 13 unless ($configs{$file})
119 0 23 unless $configs{$file}
126 0 23 unless $params_hash
135 0 23 if ('HASH' ne ref $field)
140 0 23 unless ($field->{'validation'})
144 0 23 if ('HASH' ne ref $field->{'validation'})
152 7 16 if ($field->{'validation'}{'required'}) { }
156 2 5 if (ref $value and 'HASH' eq ref $value)
166 5 22 unless defined $params{$name}
168 3 19 if $rule eq 'required'
177 3 16 if (not $ref) { }
6 10 elsif ($ref eq 'ARRAY') { }
10 0 elsif ($ref eq 'HASH') { }
184 10 0 ref $value->{'args'} ? :
191 0 19 unless (eval { do { $validation->check($method, @params); 1 } })
195 8 11 if ($validation->has_error($name))
201 4 19 if ($validation->has_error($name) and not defined $errors{$name})
215 1 106 unless $self->_load_config_from_file($c, \%configs, $file)
216 0 1 unless $configs{$file} or ref $file
221 104 2 unless $params{'fields'}
225 2 143 if %fields_to_show and not $fields_to_show{$field->{'name'}}
229 143 0 if (length $field_content)
243 0 4 unless $self->_load_config_from_file($c, \%configs, $file)
244 0 0 unless $configs{$file} or ref $file
250 0 4 unless scalar @fields_filtered
262 0 122 unless $file
264 85 1 unless ($configs->{$file} or ref $file)
271 84 5 if -r $_path
274 1 84 unless (defined $path)
283 0 84 unless (eval { do { my $content = 'Mojo::Asset::File'->new('path', $path)->slurp; $configs->{$file} = decode_json($content) } })
288 0 84 if ('ARRAY' ne ref $configs->{$file})
300 0 147 if ('HASH' ne ref $field)
308 3 1 if ($plugin_config->{'alias'} and $plugin_config->{'alias'}{$type})
312 0 147 unless ($valid_types->{$type})
317 24 4 if ($plugin_config->{'global_attributes'} and $type ne 'hidden' and 'HASH' eq ref $plugin_config->{'global_attributes'})
329 6 18 if $field_attr =~ /\Q$global_attr\E/u
331 6 12 length $field_attr ? :
337 2 0 if ($field->{'translate_sublabels'} and $plugin_config->{'translation_method'} and not $field->{'translation_method'})
352 23 124 if ($template and $type ne 'hidden')
356 1 0 if ($plugin_config->{'translate_labels'} and $loc and 'CODE' eq ref $loc)
385 0 8 $from_stash_key ? :
392 8 0 unless $field->{'attributes'}
405 1 32 $from_stash_key ? :
412 27 6 unless $field->{'attributes'}
425 1 37 $from_stash_key ? :
436 0 38 unless $stash_values
3 35 if (scalar @{[] unless $stash_values;} == 0 and defined $c->stash($name))
438 1 2 ref $local_stash ? :
441 1 37 if ($from_stash)
442 0 1 ref $from_stash ? :
446 0 38 unless $stash_values
13 25 if (@{[] unless $stash_values;})
455 7 69 if (keys %{$hashref;})
460 5 33 if ($field_params->{'data'})
466 33 5 unless $field->{'attributes'}
468 4 34 if ($field->{'multiple'})
474 18 20 if (@selected)
476 14 4 $single == 1 ? :
483 13 25 if ($reset)
485 10 3 $single == 1 ? :
495 317 69 unless $field->{$key}
499 25 44 if (not ref $field->{$key}) { }
44 0 elsif ('ARRAY' eq ref $field->{$key}) { }
516 1 38 if ($field->{'data_cb'})
521 1 0 if $sub
525 35 4 if ('ARRAY' eq ref $data) { }
4 0 elsif ('HASH' eq ref $data) { }
545 1 6 if (ref $data->{$key}) { }
553 0 6 if $params{'disabled'}{$key}
554 0 6 if $params{'selected'}{$key}
565 3 1 if (&first(sub { $_ =~ /[^0-9]/u; } , keys %mapping))
572 1 3 $numeric ? :
588 35 58 if ($numeric and $value =~ /[^0-9]/u)
594 5 88 if $params{'disabled'}{$value}
595 22 71 if $params{'selected'}{$value}
605 0 35 $numeric ? :
615 21 4 unless $field->{'attributes'}
618 17 8 ref $data ? :
628 0 25 unless $stash_values
1 24 if (scalar @{[] unless $stash_values;} == 0 and defined $c->stash($name))
630 0 1 ref $local_stash ? :
633 0 25 unless $stash_values
4 21 if (@{[] unless $stash_values;})
641 5 45 if (keys %{$hashref;})
647 6 19 if (@selected)
649 6 0 $single == 1 ? :
657 3 39 if ($select_params{'disabled'}{$radio_value})
661 6 36 if ($select_params{'selected'}{$radio_value})
666 4 38 if ($field->{'show_value'})
671 2 0 if (length $local_label and $field->{'translate_sublabels'} and $loc and 'CODE' eq ref $loc)
675 4 38 if length $local_label
684 2 40 if (defined $field->{'after_element'})
689 4 21 if ($reset)
691 4 0 $single == 1 ? :
703 24 4 unless $field->{'attributes'}
706 15 13 ref $data ? :
716 0 28 unless $stash_values
2 26 if (scalar @{[] unless $stash_values;} == 0 and defined $c->stash($name))
718 1 1 ref $local_stash ? :
721 0 28 unless $stash_values
5 23 if (@{[] unless $stash_values;})
730 6 50 if (keys %{$hashref;})
736 8 20 if (@selected)
738 7 1 $single == 1 ? :
746 3 41 if ($select_params{'disabled'}{$checkbox_value})
750 9 35 if ($select_params{'selected'}{$checkbox_value})
755 4 40 if ($field->{'show_value'})
760 2 0 if (length $local_label and $field->{'translate_sublabels'} and $loc and 'CODE' eq ref $loc)
764 4 40 if length $local_label
773 3 41 if (defined $field->{'after_element'})
778 5 23 if ($reset)
780 4 1 $single == 1 ? :
793 3 5 unless $field->{'attributes'}
804 2 4 unless $field->{'attributes'}