I'm using react/typescript
I have some file validations to perform in a file input. I want to check the names of the files are not duplicated in the upload set.
in the next example I'm testing the file names to match a criteria.
Example: SUPPORTED_NAMES = ["text", "command", "execute"]
test('fileName', 'unsuported file name', (value: FileList)=>{
for(let i = 0; i < value.lenght; i++){
const file = value.item(i);
if(file.name){
return SUPPORTED_NAMES.some((element) =>
file.name.includes(element.toLowerCase())
);
}
}
return false;
})
Now I want to check that I don't have duplicated file names... Any ideas?