API / Minn\Rest / ParamCheck

ParamCheck final class

Minn\Rest\ParamCheck · public/minn/src/Minn/Rest/ParamCheck.php · 76 lines

The required / validate / sanitize pass over a request's declared arguments. The callbacks are plugin code and may answer with a WP_Error; the caller hands them in already normalised to true, false, or [message, details].

Public

staticvalidate(array $args, callable $param, callable $validate): ?Minn\Runtime\Refusal#

The first refusal among the request's parameters, or null when all pass.

$argsarray<string, array<string, mixed>>
$paramcallable(string): mixedthe request's value for one argument
$validatecallable(string, mixed): (bool|array{0: string, 1: mixed})true, false, or [message, details]
staticsanitize(array $params, array $args, callable $sanitize): array#

The parameters after sanitising, or the refusal listing every invalid one.

$paramsarray<string, array<string, mixed>>the request's parameter groups, by source, in precedence order
$argsarray<string, array<string, mixed>>
$sanitizecallable(string, mixed): (array{value: mixed}|array{error: array{0: string, 1: mixed}})
@return array{0: array<string, array<string, mixed>>, 1: Refusal|null} the parameters after sanitising, and the refusal if any failed

Internals 1

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

privaterefusal(array $invalid, array $details): ?Minn\Runtime\Refusal#