$failures], HttpCodes::BAD_REQUEST); } }; } /** * Runs given callback, if the request's payload json validates the given schema. * @param array $schema an array of `fieldName => DefaultValidators` which represents the request object schema * @param callable(HttpRequest): HttpResponse $run the callback to run if the request is valid according to the given schema. * The callback must accept an HttpRequest, and return an HttpResponse object. * @return HttpResponse */ public static function runChecked(array $schema, callable $run): HttpResponse { return Control::runChecked($schema, $run, self::errorFactory()); } /** * Runs given callback, if the given request data array validates the given schema. * @param array $data the request's data array. * @param array $schema an array of `fieldName => DefaultValidators` which represents the request object schema * @param callable(HttpRequest): HttpResponse $run the callback to run if the request is valid according to the given schema. * The callback must accept an HttpRequest, and return an HttpResponse object. * @return HttpResponse */ public static function runCheckedFrom(array $data, array $schema, callable $run): HttpResponse { return Control::runCheckedFrom($data, $schema, $run, self::errorFactory()); } }