Skip to content

Commit 1edc1f8

Browse files
committed
Note truthy and falsy values
1 parent 6f0bec5 commit 1edc1f8

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ However, some additional input cases are handled:
2121
whitespace only values are parsed as `null`.
2222
- For `z.number()`, `z.boolean()`, `z.date()`,
2323
starting and ending whitespace is trimmed before parsing.
24-
- For `z.boolean()`, the following values are parsed as `true`:
25-
-
24+
- For `z.boolean()`, the following strings are parsed as `true`:
25+
`true`, `True`, `TRUE`, `yes`, `Yes`, `YES`, and `1`.
2626
- For `z.boolean()`, the following values are parsed as `false`:
27-
-
27+
`false`, `False`, `FALSE`, `no`, `No`, `NO`, and '0'.
2828
- Parses `z.array()` in the following formats.
2929
In order to support unambiguous parsing, array string values
3030
containing a `,` are not supported.

test/edge-cases.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@ test('pass though number values that do not parse as number', (t) => {
2323
},
2424
)
2525
})
26-
test.todo(
27-
'pass though boolean values that do not parse as truthy or falsy values',
28-
)
26+
27+
test('pass though boolean values that do not parse as truthy or falsy values', (t) => {
28+
t.deepEqual(parseUrlSearchParams('foo=a', z.object({ foo: z.boolean() })), {
29+
foo: 'a',
30+
})
31+
t.deepEqual(parseUrlSearchParams('foo=tRue', z.object({ foo: z.number() })), {
32+
foo: 'tRue',
33+
})
34+
})
2935

3036
// e.g., foo.bar= would conflict with foo.bar.a= or foo.bar.b=2
3137
// since this would be a null object containing values (null is still a value).

0 commit comments

Comments
 (0)