Skip to content

Commit

Permalink
fix: "validateFiles" can receive an array of both SelectedFile and File
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed May 1, 2019
1 parent 76baede commit 69d62c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Render prop gives you access to three callbacks:
| Prop | Type | Description |
| :------------------ | :-------------------------------------- | :----------------------------------
| `browseFiles` | `BrowseFilesParams => void` | Once executed, file browser will be shown. Useful for file upload buttons. The callback can also accept custom `onSuccess` and `onError` callbacks, that will override the main ones. |
| `validate` | `(files: Array<SelectedFile>) => void` | Enables manual validation of files. Eg. after editing the selected image in an image editor. |
| `validate` | `(files: Array<File>) => Array<FileError>` | Enables manual validation of files. Eg. after editing the selected image in an image editor. |
| `getDropZoneProps` | `(additionalProps: ?Object) => Object` | Props that need to be spread to a drop zone. Additional props can be passed, for example `className` or `style`. |
| `getLabelProps` | `(additionalProps: ?Object) => Object` | Props that need to be spread to your file field's label. Additional props can be passed, for example `className` or `style`. |

Expand Down
4 changes: 2 additions & 2 deletions src/Files.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type FileError = {
| "multipleMaxSizeExceeded"
| "multipleMaxCountExceeded"
| "multipleNotAllowed",
file?: SelectedFile
file?: SelectedFile | File
};

export type BrowseFilesParams = {
Expand Down Expand Up @@ -73,7 +73,7 @@ class Files extends React.Component<Props> {
this.id = generateId();
}

validateFiles(files: Array<SelectedFile>): Array<Object> {
validateFiles(files: Array<SelectedFile> | Array<File>): Array<FileError> {
const { multiple, multipleMaxSize, multipleMaxCount, accept, maxSize } = this.props;

const errors: Array<FileError> = [];
Expand Down

0 comments on commit 69d62c3

Please sign in to comment.