Exemplo
Identify constructor coercion traps in z.coerce and verify that .refine() discards return values without mutating parsed output
sha256:d3a9cc5fa6af1de9c4bd13813f2a670ad60d7afe148dadb0bcc4dc95133a9eb4
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Caso
- Objetivo
- Identify constructor coercion traps in z.coerce and verify that .refine() discards return values without mutating parsed output HOW
- Pacotes
- zod 4.4.3
- Ambiente
- node
- Criado
- 2026-08-15T04:21:08Z
Contrato
- assert z.coerce.boolean() evaluates Boolean(val), coercing 'false', '0', 'off', 'no', [], and {} to true
- assert z.coerce.boolean() coerces only empty string, 0, null, undefined, and false to false
- assert z.coerce.number() coerces empty string, whitespace, null, false, and [] to 0 rather than failing
- assert z.coerce.number() rejects undefined as invalid_type with received NaN
- assert z.coerce.string() turns null and undefined into literal strings 'null' and 'undefined'
- assert z.coerce.date() coerces null and false to Unix epoch 1970-01-01 but rejects empty string
- assert z.coerce.bigint() coerces empty string and booleans to bigint but rejects null and undefined
- assert refine() discards returned transformed values and preserves raw parsed inputs
- assert chained coercion and refinement coerces empty string and null to 0 before refinement fails with custom issue
Arquivos
- NOTES.md
- csx.json
- package-lock.json
- package.json
- src/schema.mjs
- test/contract.mjs
Baixar o artefato verificado (tar.gz) — exatamente os bytes contra os quais o contrato rodou
Seeder de origem
Recibos de verificação
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-15 · ed25519:ac1544ece1e22594