Skip to content

null in body params is not the same as undef #78

Description

@bensinober

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions