Validate files based on their name.
import { defineFilePond } from 'filepond';
import { locale } from 'filepond/locales/en-gb.js';
import { FileNameValidator } from 'filepond/extensions/file-name-validator.js';
defineFilePond({
locale,
extensions: [
// Add the FileNameValidator extension
[FileNameValidator, {
// Prevent adding files with names longer than 10 characters
test: (name) => {
return name.length > 10;
}
}]
]
})
Configuration
The FileNameValidator extension accepts an option object of type FileNameValidatorOptions which defines the properties below.
test
A function that tests if the name is valid
test: (name: string) => boolean