Skip to content
Discussion options

You must be logged in to vote

it's a query string

It is the answer to your question, @PseudoResonance

When parsing GET request, the query is a string, all its parameters are strings.
So there must be some interpretation implemented that could treat some of those strings as "truthy" or "falsy" in order to get booleans out of them.

You can't have z.boolean() in input schema for GET request directly — it won't pass the validation, because the typeof is still string. You can have a string-based schema, having a transformer to boolean. z.stringbool() is a flexibly configurable shorthand for that purpose.

If you want booleans, use a request that supports body, for instance — POST.
The body os JSON encoded, so that its par…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@PseudoResonance
Comment options

@RobinTail
Comment options

@PseudoResonance
Comment options

Answer selected by RobinTail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants