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)
68 2 3 unless $file =~ /\.json\z/
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
252 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})
301 0 147 if ('HASH' ne ref $field)
309 3 1 if ($plugin_config->{'alias'} and $plugin_config->{'alias'}{$type})
313 0 147 unless ($valid_types->{$type})
318 24 4 if ($plugin_config->{'global_attributes'} and $type ne 'hidden' and 'HASH' eq ref $plugin_config->{'global_attributes'})
327 6 18 if $field_attr =~ /\Q$global_attr\E/
329 6 12 length $field_attr ? :
335 2 0 if ($field->{'translate_sublabels'} and $plugin_config->{'translation_method'} and not $field->{'translation_method'})
346 23 124 if ($template and $type ne 'hidden')
350 1 0 if ($plugin_config->{'translate_labels'} and $loc and 'CODE' eq ref $loc)
377 0 8 $from_stash_key ? :
385 8 0 unless $field->{'attributes'}
397 1 32 $from_stash_key ? :
405 27 6 unless $field->{'attributes'}
417 1 37 $from_stash_key ? :
428 0 38 unless $stash_values
3 35 if (scalar @{[] unless $stash_values;} == 0 and defined $c->stash($name))
430 1 2 ref $local_stash ? :
433 1 37 if ($from_stash)
434 0 1 ref $from_stash ? :
438 0 38 unless $stash_values
13 25 if (@{[] unless $stash_values;})
449 7 69 if (keys %{$hashref;})
454 5 33 if ($field_params->{'data'})
460 33 5 unless $field->{'attributes'}
462 4 34 if ($field->{'multiple'})
468 18 20 if (@selected)
470 14 4 $single == 1 ? :
477 13 25 if ($reset)
479 10 3 $single == 1 ? :
489 317 69 unless $field->{$key}
493 25 44 if (not ref $field->{$key}) { }
44 0 elsif ('ARRAY' eq ref $field->{$key}) { }
510 1 38 if ($field->{'data_cb'})
515 1 0 if $sub
519 35 4 if ('ARRAY' eq ref $data) { }
4 0 elsif ('HASH' eq ref $data) { }
539 1 6 if (ref $data->{$key}) { }
547 0 6 if $params{'disabled'}{$key}
548 0 6 if $params{'selected'}{$key}
558 3 1 if (&first(sub { $_ =~ /[^0-9]/; } , keys %mapping))
564 1 3 $numeric ? :
580 35 58 if ($numeric and $value =~ /[^0-9]/)
586 5 88 if $params{'disabled'}{$value}
587 22 71 if $params{'selected'}{$value}
595 0 35 $numeric ? :
605 21 4 unless $field->{'attributes'}
608 17 8 ref $data ? :
618 0 25 unless $stash_values
1 24 if (scalar @{[] unless $stash_values;} == 0 and defined $c->stash($name))
620 0 1 ref $local_stash ? :
623 0 25 unless $stash_values
4 21 if (@{[] unless $stash_values;})
633 5 45 if (keys %{$hashref;})
639 6 19 if (@selected)
641 6 0 $single == 1 ? :
649 3 39 if ($select_params{'disabled'}{$radio_value})
653 6 36 if ($select_params{'selected'}{$radio_value})
658 4 38 if ($field->{'show_value'})
663 2 0 if (length $local_label and $field->{'translate_sublabels'} and $loc and 'CODE' eq ref $loc)
667 4 38 if length $local_label
676 2 40 if (defined $field->{'after_element'})
681 4 21 if ($reset)
683 4 0 $single == 1 ? :
695 24 4 unless $field->{'attributes'}
698 15 13 ref $data ? :
708 0 28 unless $stash_values
2 26 if (scalar @{[] unless $stash_values;} == 0 and defined $c->stash($name))
710 1 1 ref $local_stash ? :
713 0 28 unless $stash_values
5 23 if (@{[] unless $stash_values;})
724 6 50 if (keys %{$hashref;})
730 8 20 if (@selected)
732 7 1 $single == 1 ? :
740 3 41 if ($select_params{'disabled'}{$checkbox_value})
744 9 35 if ($select_params{'selected'}{$checkbox_value})
749 4 40 if ($field->{'show_value'})
754 2 0 if (length $local_label and $field->{'translate_sublabels'} and $loc and 'CODE' eq ref $loc)
758 4 40 if length $local_label
767 3 41 if (defined $field->{'after_element'})
772 5 23 if ($reset)
774 4 1 $single == 1 ? :
787 3 5 unless $field->{'attributes'}
798 2 4 unless $field->{'attributes'}