2

I am creating a model using Prisma 2 and want to set a minimum and maximum length for one of the fields. I.e., something like this:

model Post {
 ...
 title String @min(3) @max(240)
 ...
}

I just made up the above syntax. I am wondering if something like that exists in Prisma and, if so, how to do it.

Any ideas?

Thanks.

4

1 回答 1

4

Annotation @db.VarChar

You can set the maximum length using the annotation @db.VarChar:

model Post {
 ...
 title String @db.VarChar(240)
 ...
}

There is no support for adding the minimum length as for now.

于 2021-07-07T20:13:25.327 回答