-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
[BUG] VarChar size is ignored #261
Comments
This is also confirmed |
I don't know if this was done automatically before, which then it could be considered a bug, but if it wasn't then it isn't necessarily a bug, more like a missing feature. For now you can use Field Validators to achieve what you want! generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-openssl-3.0.x", "debian-openssl-3.0.x"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator zod {
provider = "zod-prisma-types"
}
model contacts {
id Int @id @default(autoincrement())
/// @zod.string.max(50, { message: "Error message" })
name String @db.VarChar(50)
/// @zod.string.max(50, { message: "Error message" })
surname String @db.VarChar(50)
/// @zod.string.max(50, { message: "Error message" })
supplier String @db.VarChar(50)
/// @zod.string.max(50, { message: "Error message" })
email String? @db.VarChar(50)
/// @zod.string.max(30, { message: "Error message" })
phone String? @db.VarChar(30)
/// @zod.string.max(50, { message: "Error message" })
country String @db.VarChar(50)
note String?
} Tho I understand what you mean, it should be automatically detected, I agree this should be done by the package automatically. |
That way your database field can support even the most unusual email addresses. ReferencesRFC 5321 - Section 4.5.3.1.1 to Section 4.5.3.1.2 |
Actually, searching a little bit more has shown me two errata in the mentioned RFC 3696 The erratum 1003 changed this value from 320 to 256 characters. But this also was not precisely correct, then the erratum 1690 changed this value from 256 to 254 characters. A good Stack Overflow answer that explains this well can be found here So I believe the actual recommended size is |
Describe the bug
I have a prisma model where a size of VarChar fields is limited to a certain number of chars. The limit is not reflected in the generated zod schema
Scheme
Output
Package versions (please complete the following information):
The text was updated successfully, but these errors were encountered: