API / Minn\Rest / ArgCheck

ArgCheck final readonly class

Minn\Rest\ArgCheck · public/minn/src/Minn/Rest/ArgCheck.php · 142 lines

Judges a route's declared arguments against the request before the policy is judged, the way the reference does: a required parameter that did not arrive is rest_missing_callback_param; the shared collection parameters (context, page, per_page, search) are judged first and a refusal among them is answered alone; then every other invalid one is listed in rest_invalid_param, in the order the route declares them, with the schema's own refusal under details (none for an argument whose refusal is bare, Args::BARE_REFUSAL). An argument judged in the sanitize round (Args::SANITIZE_ROUND) is read only once all the others passed. The query is read against the route's args, the JSON body against its body set, and a JSON body that does not parse is refused on every route first. An argument its handler judges (Args::HANDLER_VALIDATES) is left to the handler.

Constants and properties

privatereadonly Minn\Rest\Schema $schema

Promoted from the constructor.

Public

new__construct(Minn\Rest\Schema $schema)#
methodclosure(): Closure#

The check as the router takes it.

methodcheck(Minn\Http\Route $route, Minn\Http\Request $request, array $captures = array ( )): void#

Throws the refusal the declared arguments earn, or returns. @param array<string, string> $captures what the path named, for a route whose parameters depend on it

$capturesarray<string, string>what the path named, for a route whose parameters depend on it

Internals 6

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatejson(Minn\Http\Request $request): void#

A JSON body that does not parse is refused on every route, before its arguments are read; an empty one is not a body.

privatemissing(array $args, array $values): void#
$argsarray<string, array<string, mixed>>
$valuesarray<string, mixed>
privateround(array $sources): void#
$sourceslist<array{0: array<string, array<string, mixed>>, 1: array<string, mixed>}>
privatesanitizeRound(array $sources): void#

The arguments the reference judges once every other one passed, in its sanitize round: each may be empty, and is otherwise held to its schema; a user's password may not be empty or hold a backslash.

$sourceslist<array{0: array<string, array<string, mixed>>, 1: array<string, mixed>}>
privatepassword(mixed $value): ?Minn\Runtime\Refusal#

A user's password the reference will not store: empty, or holding a backslash.

privaterefuse(array $invalid, array $details): void#

rest_invalid_param naming every refused argument, when there is one.

$invalidarray<string, string>
$detailsarray<string, array<string, mixed>>