Skip to content

Commit e20c312

Browse files
committed
add fileValidateSizeFilter hook
1 parent 9725c0e commit e20c312

File tree

6 files changed

+37
-13
lines changed

6 files changed

+37
-13
lines changed

dist/filepond-plugin-file-validate-size.esm.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* FilePondPluginFileValidateSize 2.1.3
2+
* FilePondPluginFileValidateSize 2.2.0
33
* Licensed under MIT, https://opensource.org/licenses/MIT/
44
* Please visit https://pqina.nl/filepond/ for details.
55
*/
@@ -38,8 +38,13 @@ const plugin = ({ addFilter, utils }) => {
3838
new Promise((resolve, reject) => {
3939
// if not allowed, all fine, exit
4040
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) {
41-
resolve(file);
42-
return;
41+
return resolve(file);
42+
}
43+
44+
// check if file should be filtered
45+
const fileFilter = query('GET_FILE_VALIDATE_SIZE_FILTER');
46+
if (fileFilter && !fileFilter(file)) {
47+
return resolve(file);
4348
}
4449

4550
// reject or resolve based on file size
@@ -114,6 +119,9 @@ const plugin = ({ addFilter, utils }) => {
114119
// Max total file size in bytes
115120
maxTotalFileSize: [null, Type.INT],
116121

122+
// Filter the files that need to be validated for size
123+
fileValidateSizeFilter: [null, Type.FUNCTION],
124+
117125
// error labels
118126
labelMinFileSizeExceeded: ['File is too small', Type.STRING],
119127
labelMinFileSize: ['Minimum file size is {filesize}', Type.STRING],

dist/filepond-plugin-file-validate-size.esm.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/filepond-plugin-file-validate-size.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* FilePondPluginFileValidateSize 2.1.3
2+
* FilePondPluginFileValidateSize 2.2.0
33
* Licensed under MIT, https://opensource.org/licenses/MIT/
44
* Please visit https://pqina.nl/filepond/ for details.
55
*/
@@ -52,8 +52,13 @@
5252
return new Promise(function(resolve, reject) {
5353
// if not allowed, all fine, exit
5454
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) {
55-
resolve(file);
56-
return;
55+
return resolve(file);
56+
}
57+
58+
// check if file should be filtered
59+
var fileFilter = query('GET_FILE_VALIDATE_SIZE_FILTER');
60+
if (fileFilter && !fileFilter(file)) {
61+
return resolve(file);
5762
}
5863

5964
// reject or resolve based on file size
@@ -133,6 +138,9 @@
133138
// Max total file size in bytes
134139
maxTotalFileSize: [null, Type.INT],
135140

141+
// Filter the files that need to be validated for size
142+
fileValidateSizeFilter: [null, Type.FUNCTION],
143+
136144
// error labels
137145
labelMinFileSizeExceeded: ['File is too small', Type.STRING],
138146
labelMinFileSize: ['Minimum file size is {filesize}', Type.STRING],

dist/filepond-plugin-file-validate-size.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "filepond-plugin-file-validate-size",
3-
"version": "2.1.3",
3+
"version": "2.2.0",
44
"description": "File Size Validation Plugin for FilePond",
55
"license": "MIT",
66
"author": {

src/js/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@ const plugin = ({ addFilter, utils }) => {
3131

3232
// if not allowed, all fine, exit
3333
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) {
34-
resolve(file);
35-
return;
34+
return resolve(file);
35+
}
36+
37+
// check if file should be filtered
38+
const fileFilter = query('GET_FILE_VALIDATE_SIZE_FILTER');
39+
if (fileFilter && !fileFilter(file)) {
40+
return resolve(file);
3641
}
3742

3843
// reject or resolve based on file size
@@ -120,6 +125,9 @@ const plugin = ({ addFilter, utils }) => {
120125
// Max total file size in bytes
121126
maxTotalFileSize: [null, Type.INT],
122127

128+
// Filter the files that need to be validated for size
129+
fileValidateSizeFilter: [null, Type.FUNCTION],
130+
123131
// error labels
124132
labelMinFileSizeExceeded: ['File is too small', Type.STRING],
125133
labelMinFileSize: ['Minimum file size is {filesize}', Type.STRING],

0 commit comments

Comments
 (0)