ZodZ
Zodโ€ข2y ago
janglad

janglad - This seems like it might be worth a b...

This seems like it might be worth a bug report/request but does anyone know if there's a good way around this? I assume internally
message
is being evaluated as truthy/falsy and thus an empty string isn't picked up

import z from 'zod';

z.number().min(0, { message: '' }).parse(-1);

/* 
Error: [
{
"code": "too_small",
"minimum": 0,
"type": "number",
"inclusive": true,
"exact": false,
"message": "Number must be greater than or equal to 0",
"path": []
}
]
*/
Was this page helpful?