Skip to content

Commit cdf8de8

Browse files
committed
add minFileSize option and related warning labels
1 parent d3ac591 commit cdf8de8

File tree

5 files changed

+73
-11
lines changed

5 files changed

+73
-11
lines changed

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

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/*
2-
* FilePondPluginFileValidateSize 2.0.0
2+
* FilePondPluginFileValidateSize 2.1.0
33
* Licensed under MIT, https://opensource.org/licenses/MIT
44
* Please visit https://pqina.nl/filepond for details.
55
*/
6+
7+
/* eslint-disable */
68
var plugin$1 = ({ addFilter, utils }) => {
79
// get quick reference to Type utils
810
const { Type, replaceInString, toNaturalFileSize } = utils;
@@ -14,9 +16,15 @@ var plugin$1 = ({ addFilter, utils }) => {
1416
}
1517

1618
const sizeMax = query('GET_MAX_FILE_SIZE');
17-
if (sizeMax !== null && file.size > sizeMax) {
19+
if (sizeMax !== null && file.size >= sizeMax) {
1820
return false;
1921
}
22+
23+
const sizeMin = query('GET_MIN_FILE_SIZE');
24+
if (sizeMin !== null && file.size <= sizeMin) {
25+
return false;
26+
}
27+
2028
return true;
2129
});
2230

@@ -35,7 +43,7 @@ var plugin$1 = ({ addFilter, utils }) => {
3543

3644
// reject or resolve based on file size
3745
const sizeMax = query('GET_MAX_FILE_SIZE');
38-
if (sizeMax !== null && file.size > sizeMax) {
46+
if (sizeMax !== null && file.size >= sizeMax) {
3947
reject({
4048
status: {
4149
main: query('GET_LABEL_MAX_FILE_SIZE_EXCEEDED'),
@@ -47,6 +55,20 @@ var plugin$1 = ({ addFilter, utils }) => {
4755
return;
4856
}
4957

58+
// reject or resolve based on file size
59+
const sizeMin = query('GET_MIN_FILE_SIZE');
60+
if (sizeMin !== null && file.size <= sizeMin) {
61+
reject({
62+
status: {
63+
main: query('GET_LABEL_MIN_FILE_SIZE_EXCEEDED'),
64+
sub: replaceInString(query('GET_LABEL_MIN_FILE_SIZE'), {
65+
filesize: toNaturalFileSize(sizeMin)
66+
})
67+
}
68+
});
69+
return;
70+
}
71+
5072
// returns the current option value
5173
const totalSizeMax = query('GET_MAX_TOTAL_FILE_SIZE');
5274
if (totalSizeMax !== null) {
@@ -85,12 +107,19 @@ var plugin$1 = ({ addFilter, utils }) => {
85107
// Max individual file size in bytes
86108
maxFileSize: [null, Type.INT],
87109

110+
// Min individual file size in bytes
111+
minFileSize: [null, Type.INT],
112+
88113
// Max total file size in bytes
89114
maxTotalFileSize: [null, Type.INT],
90115

91116
// error labels
117+
labelMinFileSizeExceeded: ['File is too small', Type.STRING],
118+
labelMinFileSize: ['Minimum file size is {filesize}', Type.STRING],
119+
92120
labelMaxFileSizeExceeded: ['File is too large', Type.STRING],
93121
labelMaxFileSize: ['Maximum file size is {filesize}', Type.STRING],
122+
94123
labelMaxTotalFileSizeExceeded: [
95124
'Maximum total size exceeded',
96125
Type.STRING

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

Lines changed: 4 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: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/*
2-
* FilePondPluginFileValidateSize 2.0.0
2+
* FilePondPluginFileValidateSize 2.1.0
33
* Licensed under MIT, https://opensource.org/licenses/MIT
44
* Please visit https://pqina.nl/filepond for details.
55
*/
6+
7+
/* eslint-disable */
68
(function(global, factory) {
79
typeof exports === 'object' && typeof module !== 'undefined'
810
? (module.exports = factory())
@@ -31,9 +33,15 @@
3133
}
3234

3335
var sizeMax = query('GET_MAX_FILE_SIZE');
34-
if (sizeMax !== null && file.size > sizeMax) {
36+
if (sizeMax !== null && file.size >= sizeMax) {
3537
return false;
3638
}
39+
40+
var sizeMin = query('GET_MIN_FILE_SIZE');
41+
if (sizeMin !== null && file.size <= sizeMin) {
42+
return false;
43+
}
44+
3745
return true;
3846
});
3947

@@ -51,7 +59,7 @@
5159

5260
// reject or resolve based on file size
5361
var sizeMax = query('GET_MAX_FILE_SIZE');
54-
if (sizeMax !== null && file.size > sizeMax) {
62+
if (sizeMax !== null && file.size >= sizeMax) {
5563
reject({
5664
status: {
5765
main: query('GET_LABEL_MAX_FILE_SIZE_EXCEEDED'),
@@ -63,6 +71,20 @@
6371
return;
6472
}
6573

74+
// reject or resolve based on file size
75+
var sizeMin = query('GET_MIN_FILE_SIZE');
76+
if (sizeMin !== null && file.size <= sizeMin) {
77+
reject({
78+
status: {
79+
main: query('GET_LABEL_MIN_FILE_SIZE_EXCEEDED'),
80+
sub: replaceInString(query('GET_LABEL_MIN_FILE_SIZE'), {
81+
filesize: toNaturalFileSize(sizeMin)
82+
})
83+
}
84+
});
85+
return;
86+
}
87+
6688
// returns the current option value
6789
var totalSizeMax = query('GET_MAX_TOTAL_FILE_SIZE');
6890
if (totalSizeMax !== null) {
@@ -102,12 +124,19 @@
102124
// Max individual file size in bytes
103125
maxFileSize: [null, Type.INT],
104126

127+
// Min individual file size in bytes
128+
minFileSize: [null, Type.INT],
129+
105130
// Max total file size in bytes
106131
maxTotalFileSize: [null, Type.INT],
107132

108133
// error labels
134+
labelMinFileSizeExceeded: ['File is too small', Type.STRING],
135+
labelMinFileSize: ['Minimum file size is {filesize}', Type.STRING],
136+
109137
labelMaxFileSizeExceeded: ['File is too large', Type.STRING],
110138
labelMaxFileSize: ['Maximum file size is {filesize}', Type.STRING],
139+
111140
labelMaxTotalFileSizeExceeded: [
112141
'Maximum total size exceeded',
113142
Type.STRING

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

Lines changed: 4 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.0.0",
3+
"version": "2.1.0",
44
"description": "File Size Validation Plugin for FilePond",
55
"homepage": "https://pqina.nl/filepond",
66
"repository": "pqina/filepond-plugin-file-validate-size",

0 commit comments

Comments
 (0)