By providing `validator` prop you can specify custom validation for files. The value must be a function that accepts File object and returns null if file should be accepted or error object/array of error objects if file should be rejected. ```jsx harmony import React from 'react'; import {useDropzone} from 'react-dropzone'; const maxLength = 20; function nameLengthValidator(file) { if (file.name.length > maxLength) { return { code: "name-too-large", message: `Name is larger than ${maxLength} characters` }; } return null } function CustomValidation(props) { const { acceptedFiles, fileRejections, getRootProps, getInputProps } = useDropzone({ validator: nameLengthValidator }); const acceptedFileItems = acceptedFiles.map(file => (
Drag 'n' drop some files here, or click to select files
(Only files with name less than 20 characters will be accepted)