StructuredParameters/Exception/MissingParameter.pm

filter: Statementstmt 66.6% 14 / 21 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 57.1% 4 / 7 Podpod 100% 3 / 3 totaltotal 48.8% 21 / 43 CC 5 SCAR 19.6
CC
5
Cov
47%
param
12.0
missing
12.0
message
2.0
CRAP 7.1
« StructuredParameters.pm ↑ Summary StructuredParameters/Request.pm »
1 package PAGI::StructuredParameters::Exception::MissingParameter;
2 5 $PAGI::StructuredParameters::Exception::MissingParameter::VERSION = '0.001001';
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use parent -norequire, 'PAGI::StructuredParameters::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use PAGI::StructuredParameters::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # Raised by 'required' when one or more required keys are absent. 'missing' holds
9 # the full list of missing dotted key paths; 'param' is the first, for a concise
10 # single-line message.
11  
12 0 ▶sub param { my ($self) = @_; $self->{param} // ($self->{missing} // [])->[0] }
Subroutine param: not called CC=3 SCAR=24.8
Pod documented
Condition0%0/5
$self->{"param"} // +($self->{"missing"} // [])->[0]
l!l&&r!l&&!r
000
$self->{"missing"} // []
l!l
00
MC/DC0%0/2
$self->{"param"} // +($self->{"missing"} // [])->[0]
$self->{"param"} $self->{"missing"}
Truth table0%0/3
A // B
A= $self->{"param"}B= $self->{"missing"}
ABresult
1X1
011
000
13  
14 0 ▶sub missing { my ($self) = @_; $self->{missing} // [defined $self->{param} ? $self->{param} : ()] }
Subroutine missing: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'param'} ? : 0 0 0
Condition0%0/2
$self->{"missing"} // [defined $self->{"param"} ? $self->{"param"} : ()]
l!l
00
MC/DC0%0/1
$self->{"missing"} // [defined $self->{"param"} ? $self->{"param"} : ()]
$self->{"missing"}
Truth table0%0/2
A
A= $self->{"missing"}
Aresult
11
00
15  
16 0 ▶sub message {
Subroutine message: not called CC=1 SCAR=6.9
Pod documented
17 0 my ($self) = @_;
18 0 return "Required parameter '@{[ $self->param ]}' is missing.";
19 }
20  
21 5 1;
22  
23 =encoding utf8
24  
25 =head1 NAME
26  
27 PAGI::StructuredParameters::Exception::MissingParameter - A required parameter was absent
28  
29 =head1 DESCRIPTION
30  
31 Raised by L<PAGI::StructuredParameters/required> when one or more required keys
32 are absent from the incoming parameters. Subclass of
33 L<PAGI::StructuredParameters::Exception> (HTTP status 400).
34  
35 =head1 METHODS
36  
37 =head2 param
38  
39 The first missing key path (e.g. C<'person.name'>).
40  
41 =head2 missing
42  
43 An arrayref of all missing key paths detected during the parse.
44  
45 =head2 message
46  
47 "Required parameter 'person.name' is missing."
48  
49 =head1 AUTHOR
50  
51 John Napiorkowski C<< <jjnapiork@cpan.org> >>
52  
53 =head1 COPYRIGHT & LICENSE
54  
55 Copyright 2026, John Napiorkowski. This library is free software; you can
56 redistribute it and/or modify it under the same terms as Perl itself.
57  
58 =cut
« StructuredParameters.pm ↑ Summary StructuredParameters/Request.pm »