8

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.

Moshe
  • 6,011
  • 16
  • 60
  • 112

1 Answers1

19

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.

Yogesh Umesh Vaity
  • 41,009
  • 21
  • 145
  • 105