lokalise/zod-extras

toNumberPreprocessor converts empty string to 0

Gambitier opened this issue · 1 comments

javascript converts empty string to 0. So if the this preprocessor is applied for number and if input is empty string then after transformation we receive value 0 which is number and hence zod doesn't throw any error

console.log(+''); // 0

if (typeof value === 'string' && !isNaN(+value)) {
return +value
}

Thank you for the report! This has been fixed and v2.0.0 has been released.