Z
Zod10mo 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": []
}
]
*/
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": []
}
]
*/
3 Replies
Scott Trinh
Scott Trinh10mo ago
yeah, although I don't see the obvious bug in the code.
janglad
janglad10mo ago
alright made an issue, thank you 👍 https://github.com/colinhacks/zod/issues/3101
GitHub
Empty error message gets evaluated as falsy and overriden · Issue #...
Doing this import z from 'zod'; z.number().min(0, { message: '' }).parse(-1); Results in an error of Error: [ { "code": "too_small", "minimum": 0, &quo...
Want results from more Discord servers?
Add your server