Validation
Dredge let you define validations for the data, params, search params. You can use zod, superstruct or yup for creating schema.
On Failure of validation, Dredge will throw ValidationError
. You can handle the error by using route.error().
Params
Before defining schema for param, be sure to define path.
ts
import { route } from './route'
route.path('/user/:id').params({
id: z.number()
})
SearchParams
ts
import { route } from './route'
route.path('/entries').searchParams({
skip: z.number(),
})
Data
ts
import { route } from './route'
route.path('/blog').post(z.object());
route.path('/blog/:id').put(
z.object().passthrough()
)
route.path('/blog/:id').patch(
z.object().passthrough()
)