Thanks for this great and simple descriptive API!
I am thinking that the following code:
|
foreach my $p (@$declared) { |
|
my $name = $p->name; |
|
my $value = $params{$name}; |
|
|
|
if (not $p->validate(\$value)) { |
|
$p->required ? return : next; |
|
} |
|
|
|
$value //= $p->default if defined $p->default; |
|
next if not defined($value); |
|
|
|
$self->{'raisin.declared_params'}{$name} = $value; |
|
} |
will filter out also defined null values in JSON body, which makes it difficult to define optional params that can be null, meaning a typical PUT or PATCH request to "unset" a value. Say, you have a DB column that needs to be NULLed.
Of course, you still get the "undef"s from req->raisin_parameters, so it can easily be circumvented, but I am still unsure why "undef"s should be removed from declared_params and params?
Is line 34 actually neccessary, is my point.
Thanks for this great and simple descriptive API!
I am thinking that the following code:
Raisin/lib/Raisin/Request.pm
Lines 25 to 37 in 7e460ee
will filter out also defined null values in JSON body, which makes it difficult to define optional params that can be null, meaning a typical PUT or PATCH request to "unset" a value. Say, you have a DB column that needs to be NULLed.
Of course, you still get the "undef"s from req->raisin_parameters, so it can easily be circumvented, but I am still unsure why "undef"s should be removed from declared_params and params?
Is line 34 actually neccessary, is my point.