Add rejectionReason property to rejected files #257

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@rrhvella
rrhvella commented Oct 19, 2016 edited

The rationale behind this is that I want to inform the user about the reason that a particular file was rejected. With this property I can listen to onDropRejected or onDrop, add the rejected files to my list, and display a tooltip giving the reason as translated text.

rejectionReason is only defined on rejected files. And has one of three possible values.

1 = InvalidFileType
2 = BelowMinSize
3 = AboveMaxSize

These values are listed on the RejectionReason enum which is a static property on the Dropzone class.

Dropzone.RejectionReason = { InvalidFileType: 1, BelowMinSize: 2, AboveMaxSize: 3 };

Thank you for the good work and I look forward to your feedback.

@rrhvella rrhvella Rejected files now include a property (rejectedReason) which gives th…
…e reason for rejection (1 = InvalidFileType, 2 = BelowMinSize, 3 = AboveMaxSize)
6e19fa6
@kandros
kandros commented Jan 10, 2017

LGTM

@okonet okonet referenced this pull request Jan 11, 2017
Closed

Custom validators #321

@okonet
Owner
okonet commented Jan 11, 2017

First of all thanks for your contribution and sorry, I dropped the ball on it. I'm still not sure the design of this feature is complete enough. For example, when trying to drop several files, each of this files can be rejected with a different reason. Question: what reason will be passed in this case?

I was thinking about implementing custom validators and would like to discuss it in a separate issue here: #321

@kandros
kandros commented Jan 11, 2017 edited

For example, when trying to drop several files, each of this files can be rejected with a different reason. Question: what reason will be passed in this case

as shown here https://github.com/okonet/react-dropzone/pull/257/files#diff-1fdf421c05c1140f6d71444ea2b27638R130 the reason of failure gets injected to the file itself

so in this.props.onDropRejected.call(this, rejectedFiles, e) the rejected files array have reasons

@okonet
Owner
okonet commented Jan 20, 2017

Closing based on #321

@okonet okonet closed this Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment