Unique validation

Hi,
The following code validates the unique folder_name for all users
I need to validate the unique folder_name for the current user.

rules = {
            folder_name: 'required|unique:folders,folder_name',
  }

eg:
case1:
If I try to add the same folder_name to different users it should be valid
user1 -> folder_name = ‘adonis’ --> valid
user2 -> folder_name = ‘adonis’ --> valid

case2:
If I try to add the same folder_name to the same user it should be invalid
user1 -> folder_name = ‘adonis’ --> not valid
user1 -> folder_name = ‘adonis’ --> not valid

now get to the point:
Are there any predefined methods to achieve the above things?

I have a custom method but using a framework’s defined method is good practice

1 Like

You will need to setup a custom validation when you want to check uniques against multiple fields.