Prisma allowing empty DB fields
Hey guys. Day one of using Prisma, so probably something simple Im missing or not understanding. From reading docs, if no type modifer is provided, the default behaviour is fields are not null. That being said, it is letting me submit records without certain fields missing. I have created records through both my TRPC endpoint, and Prisma Studio, and in both I can omit a field and it doesn't reject it. Attached a screenshot of my model and an example record. Any ideas?
![](https://utfs.io/f/e291ba17-b12a-4232-9b74-765cd835db5f-qawmr6.33.19_pm.png)
8 Replies
![](https://utfs.io/f/39a0d923-ec5f-4341-8ff1-30842b4c94b1-qawmr6.36.00_pm.png)
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I don't want them optional, thats the issue. I want them mandatory, have not added the ?, yet it allows records with empty fields
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Anyway I can check? when I click into the field in prisma studio it shows null
![](https://utfs.io/f/e782a04f-68fc-4830-819a-27573d057eb8-qawmr6.49.12_pm.png)
I can use do a minimum length on the TRPC endpoint with z.string().min(3) but would rather have the validation at the DB level itself
Hey Cody, isn't this tied to what DB you're using rather than Prisma only?
Like generally if you don't add a question mark, if the DB Supports it, it should not be null.
Just using default sqlite for dev, haven't tested on deployment which is using Planetscale
I'll give it a shot in prod db and see what happens