Skip to content

standard-schema support for runtime validation with Zod, Valibot, etc. #730

@olsio

Description

@olsio

ky currently simply casts your result to a type but it would be very useful if you could pass a schema to properly validate the received json before returning it.

https://github.com/standard-schema/standard-schema is a specification that allows support for a large number of validation libraries without tying the project to one specific.

I imagine it will be a fight to get the types correct but there are several fetch libraries that added support and might be a good source for inspiration.

https://github.com/L-Blondy/up-fetch
https://github.com/logione/rest-client

I could work on this but I think the project team needs to tell me how the api should look like to fit the vision of ky.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions