chrishoermann / zod-prisma-types

Generator creates zod types for your prisma models with advanced validation
Other
579 stars 43 forks source link

How to validate a number greater or equal than float value? #136

Closed svex99 closed 1 year ago

svex99 commented 1 year ago

Given a model like this:

model Job {
    /// @zod.number.gte(7.25, { message: "Salary must be at least $7.25/h"})
    salary Float
}

When I run the generator, I get the error:

[@zod generator error]: Could not match validator 'gte' with validatorPattern '.gte(7.25, { message: "Salary must be at least $7.25/h"})'. Please check for typos! [Error Location]: Model: 'Job', Field: 'salary'.

It works with an integer value, but how to set a float value to validate in this case?

Thanks in advance!

chrishoermann commented 1 year ago

@svex99 thanks for the report. I'll look into this

chrishoermann commented 1 year ago

@svex99 this should now be fixed in the latest version

svex99 commented 1 year ago

That was fast! Thank you for your effort!

chrishoermann commented 1 year ago

You're welcome 😉