Skip to content

Commit 9a20fcc

Browse files
committed
Restrict parsing boolean array
1 parent 05da702 commit 9a20fcc

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ However, some additional input cases are handled:
5353
- Value-types may not be `z.nullable()` or `z.undefined()`.
5454
- The value-type cannot be a `z.object()`.
5555
- The value-type cannot be an `z.array()` or contain a nested `z.array()` at any level.
56+
- The value-type cannot be a `z.boolean()`.
57+
This restriction is not strictly necessary,
58+
but a deliberate choice not to support such schemas in this version.
5659
- A `z.record()` has less-strict schema constraints but weaker parsing guarantees:
5760
- They keys must be `z.string()`.
5861
- The value-type may be a single primitive type.

src/lib/parse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ const parse = (k: string, values: string[], type: ValueType): unknown => {
5858
if (type === 'number') return parseNumber(values[0].trim())
5959
if (type === 'boolean') return parseBoolean(values[0].trim())
6060
if (type === 'string') return String(values[0])
61-
if (type === 'string_array') return values
62-
if (type === 'number_array') return values.map((v) => Number(v))
61+
if (type === 'string_array') return values.map((v) => String(v))
62+
if (type === 'number_array') return values.map((v) => parseNumber(v))
6363
throw new UnparseableSearchParamError(k, 'unsupported type')
6464
}
6565

0 commit comments

Comments
 (0)