import type { ErrorObject } from "ajv"; import { ErrorCodes, errorShape, formatValidationErrors } from "../protocol/index.js"; import type { RespondFn } from "./types.js";
export type Validator<T> = ((params: unknown) => params is T) & {
errors?: ErrorObject[] | null;
};
export function assertValidParams<T>(
params: unknown,
validate: Validator<T>,
method: string,
respond: RespondFn,
): params is T { if (validate(params)) { returntrue;
}
respond( false,
undefined,
errorShape(
ErrorCodes.INVALID_REQUEST,
`invalid ${method} params: ${formatValidationErrors(validate.errors)}`,
),
); returnfalse;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-09)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.