Skip to content
Discussion options

You must be logged in to vote

After some digging I've found a solution. When using a multi-tenant plugin in PayloadCMS 3.0, unique: true property becomes useless unless you don't want tenants sharing the values between each other, e.g. (tenant domains).

Instead of using it I've created a fully type-safe and reusable function that does not hurt the DX one bit. I am pasting it here in case someone else runs into this problem in the future, as the current docs don't mention exactly how to handle tenant level uniqueness.

export const checkFieldUniquePerTenant: Validate = async (
  val,
  { data, path, collectionSlug, operation, previousValue },
) => {
  try {
    // we skip validation for read and delete operations
    if (

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by simovicaleksa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant