Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty error message gets evaluated as falsy and overriden #3101

Closed
janglad opened this issue Jan 2, 2024 · 1 comment · Fixed by #3178
Closed

Empty error message gets evaluated as falsy and overriden #3101

janglad opened this issue Jan 2, 2024 · 1 comment · Fixed by #3178
Labels
enhancement New feature or request

Comments

@janglad
Copy link

janglad commented Jan 2, 2024

Doing this

import z from 'zod';

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

Results in an error of

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

instead of having an empty message.

Would it be possible to explicitly check if the message is undefined rather than checking if it's falsy? After asking this on the Discord scotttrinh found the line causing this

message: issueData.message || errorMessage,

@JacobWeisenburger JacobWeisenburger added the enhancement New feature or request label Jan 3, 2024
@fernandollisboa
Copy link
Contributor

I think I can manage that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants