Custom validation to avoid equal names in multiple files input

Hey everyone, I'm trying to write a custom validation rule to block files with equal names being uploaded in multiple files input. Couldn't find any other question regarding this. Is it possible? Thanks!

Hi @Vitor_Dal_Pra
Welcome to the community.
Running your query which contains the file names, and then using ternary operator in the custom validation rules might do the trick. Here is the example, you will just need to adjust it to your components

Hey @Vitor_Dal_Pra, it is definitely possible!

I assume you want to ensure your users do not accidentally upload the same files. In this case, the validation rule would look like this:

{{ => !== new Set( => ? 'Some files have the same name.' : null }}

Still if you would like to validate against the file names that already exist on the server, then @Milan_Kalem 's solution is good to go.

Hope this helps

Hey, @Milan_Kalem and @preshetin thank you for your answers!

I actually need to combine both your answers. I need to check if the name of a file in the input form is not already in the database and if this file does not match the name of other files while "in" the input.

Then you can use something like this

{{ => !== new Set( => 
  ? 'Some files have the same name.' 
  : fileDropzone1.value.some(obj =>'.')[0] ===[0]) ? "Database duplicate" : "Free to upload"


Hey @Milan_Kalem, thank you!

The code is not working for the database part. I believe it has to do with query29 returing a json, but could not figure it out on how to solve it...

This is where im stuck right now

Another two cents from me.

Why do you want to ensure the all filenames are unique?

If during saving files to your file storage you would add some random hash then the problem would go away by itself