Emmanuel Amodu
Emmanuel Amodu

Reputation: 307

Restrict string values in property

I would like to know how to restrict the possible values in a field in prisma.

My model looks like this currently

model FraudOrderCheck {
  id                 Int                  @id @default(autoincrement())
  brand_name         String
  retries            Int                  @default(0)
  validation_state   String               @default('processing') 
}

How to restrict the possible values in validation_state to this

validation_state   String               @default('processing') // processed, errored

Upvotes: 1

Views: 935

Answers (1)

Ryan
Ryan

Reputation: 6347

Prisma cannot restrict string values at the moment. You would need to handle this in your application logic.

Another workaround would be to use enums:

enum ValidationState {
  PROCESSING
  PROCESSED
  ERROR
}

Upvotes: 1

Related Questions