NAME

PAGI::StructuredParameters::Request - Request-bound, asynchronous strong parameters

SYNOPSIS

use PAGI::StructuredParameters;

my $clean = await PAGI::StructuredParameters->from_body($req)
    ->permitted('username', name => ['first', 'last'], +{ email => [] });

DESCRIPTION

Binds the PAGI::StructuredParameters engine to a live PAGI::Request. Because reading a PAGI request body is asynchronous, the terminal "permitted" and "required" methods are asynchronous: each materializes the source hash from the request (awaiting the body for body/data; the query string is read synchronously), constructs a synchronous engine, and delegates.

You normally obtain one of these from "from_body" in PAGI::StructuredParameters, "from_query" in PAGI::StructuredParameters, "from_data" in PAGI::StructuredParameters, or — in PAGI::Nano — from $c->params.

CONFIGURATION METHODS

These are synchronous and return the object for chaining before the terminal call.

namespace

$obj->namespace(['person']);

flatten_array_value

$obj->flatten_array_value(0);

max_array_depth

$obj->max_array_depth(50);

See PAGI::StructuredParameters for the meaning of each.

TERMINAL METHODS

permitted

my $clean = await $obj->permitted(@rules);

Asynchronously materializes the request source and applies "permitted" in PAGI::StructuredParameters.

required

my $clean = await $obj->required(@rules, $on_missing);

Asynchronously materializes the request source and applies "required" in PAGI::StructuredParameters. A missing required key throws the callback's return value through the await.

AUTHOR

John Napiorkowski <jjnapiork@cpan.org>

COPYRIGHT & LICENSE

Copyright 2026, John Napiorkowski. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.