Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ if (result.ok) {
Paths use OpenAPI-style `{name}` parameters. Colon parameters and wildcards are rejected. A path
parameter declaration must exactly match the names in the path.

Path values are runtime-validated or transformed only when their `.params()` entry includes a
validator. The generic in `.params<T>()` is a compile-time contract and is erased at runtime; using
`.params<T>()` without validators, or relying on auto-derived path parameters, only checks that
required names are present. Supply a validator for every path value when runtime safety or coercion
is required.

Every call returns a discriminated result instead of throwing for request, transport, HTTP, or
decode failures. Use `unwrap(result)` when exception-based control flow is more convenient.

Expand Down
4 changes: 4 additions & 0 deletions src/dsl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export interface EndpointBuilder<
E extends Errors = {},
> {
readonly [STATE]: State;
/**
* Declares path parameter types and optional runtime validators. Generic types are erased;
* runtime validation occurs only for entries whose specification includes a validator.
*/
params<T extends Record<string, unknown>>(spec?: ParameterMap): EndpointBuilder<T, Q, H, B, R, E>;
query<T extends Record<string, unknown>>(spec?: ParameterMap): EndpointBuilder<P, T, H, B, R, E>;
headers<T extends Record<string, unknown>>(
Expand Down