SearchValidationError
Thrown when the query does not validate: by a Standard Schema, or by a validateSearch function that throws it on purpose.
Thrown when the query does not validate: by a Standard Schema, or by a validateSearch function that throws it
on purpose. A different error thrown by validateSearch is an ordinary error (a bug, a server fault).
Import#
ts
import { SearchValidationError } from "@shadow-js/router";
Signature#
ts
class SearchValidationError extends Error
Members#
| Name | Type | Description |
|---|---|---|
issues |
readonly issues: readonly SearchIssue[] |
The problems, one per failing key. |
Examples#
ts
validateSearch: (search) => {
if (!/^\d+$/.test(String(search.page ?? "1"))) {
throw new SearchValidationError([{ message: "page must be a whole number", path: ["page"] }]);
}
return { page: Number(search.page ?? 1) };
}