-
-
Notifications
You must be signed in to change notification settings - Fork 795
Closed
Description
react-dropzone provides some simple validation out of the box like accept, minSize and maxSize but it lacks rejection reason (#257 and #319) so it's impossible to react to this rejection without the duplicating the validations in the user's component's code.
I have been thinking about implementing some kind of custom validator functions that you could then compose. Each such validator function should have a generic API. Something like this:
import { validate, assertMaxFileSize, assertMinFileSize, asserFileType } from 'react-dropzone'
function onValidate(files) {
const { acceptedFiles, rejectedFiles } = validate(assertMaxFileSize, assertMinFileSize, asserFileType)(files)
return [ acceptedFiles, rejectedFiles ]
}
const MyDropZone = (props) => {
return <Dropzone onValidate={onValidate} />
}This would allow create custom validators and react to rejections appropriately in the UI.
Thoughts?
ajhool, k-vosswinkel, svengau, otottkovacstibor and undefineq