filepond-plugin-file-validate-size
Advanced tools
Comparing version 2.1.3 to 2.2.0
/*! | ||
* FilePondPluginFileValidateSize 2.1.3 | ||
* FilePondPluginFileValidateSize 2.2.0 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -41,6 +41,11 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) { | ||
resolve(file); | ||
return; | ||
return resolve(file); | ||
} | ||
// check if file should be filtered | ||
const fileFilter = query('GET_FILE_VALIDATE_SIZE_FILTER'); | ||
if (fileFilter && !fileFilter(file)) { | ||
return resolve(file); | ||
} | ||
// reject or resolve based on file size | ||
@@ -118,2 +123,5 @@ const sizeMax = query('GET_MAX_FILE_SIZE'); | ||
// Filter the files that need to be validated for size | ||
fileValidateSizeFilter: [null, Type.FUNCTION], | ||
// error labels | ||
@@ -120,0 +128,0 @@ labelMinFileSizeExceeded: ['File is too small', Type.STRING], |
/*! | ||
* FilePondPluginFileValidateSize 2.1.3 | ||
* FilePondPluginFileValidateSize 2.2.0 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -9,2 +9,2 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
const e=({addFilter:e,utils:i})=>{const{Type:l,replaceInString:E,toNaturalFileSize:_}=i;return e("ALLOW_HOPPER_ITEM",(e,{query:i})=>{if(!i("GET_ALLOW_FILE_SIZE_VALIDATION"))return!0;const l=i("GET_MAX_FILE_SIZE");if(null!==l&&e.size>=l)return!1;const E=i("GET_MIN_FILE_SIZE");return!(null!==E&&e.size<=E)}),e("LOAD_FILE",(e,{query:i})=>new Promise((l,I)=>{if(!i("GET_ALLOW_FILE_SIZE_VALIDATION"))return void l(e);const t=i("GET_MAX_FILE_SIZE");if(null!==t&&e.size>=t)return void I({status:{main:i("GET_LABEL_MAX_FILE_SIZE_EXCEEDED"),sub:E(i("GET_LABEL_MAX_FILE_SIZE"),{filesize:_(t)})}});const n=i("GET_MIN_FILE_SIZE");if(null!==n&&e.size<=n)return void I({status:{main:i("GET_LABEL_MIN_FILE_SIZE_EXCEEDED"),sub:E(i("GET_LABEL_MIN_FILE_SIZE"),{filesize:_(n)})}});const s=i("GET_MAX_TOTAL_FILE_SIZE");if(null!==s){if(i("GET_ACTIVE_ITEMS").reduce((e,i)=>e+i.fileSize,0)>s)return void I({status:{main:i("GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED"),sub:E(i("GET_LABEL_MAX_TOTAL_FILE_SIZE"),{filesize:_(s)})}})}l(e)})),{options:{allowFileSizeValidation:[!0,l.BOOLEAN],maxFileSize:[null,l.INT],minFileSize:[null,l.INT],maxTotalFileSize:[null,l.INT],labelMinFileSizeExceeded:["File is too small",l.STRING],labelMinFileSize:["Minimum file size is {filesize}",l.STRING],labelMaxFileSizeExceeded:["File is too large",l.STRING],labelMaxFileSize:["Maximum file size is {filesize}",l.STRING],labelMaxTotalFileSizeExceeded:["Maximum total size exceeded",l.STRING],labelMaxTotalFileSize:["Maximum total file size is {filesize}",l.STRING]}}};"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:e}));export default e; | ||
const e=({addFilter:e,utils:i})=>{const{Type:l,replaceInString:E,toNaturalFileSize:_}=i;return e("ALLOW_HOPPER_ITEM",(e,{query:i})=>{if(!i("GET_ALLOW_FILE_SIZE_VALIDATION"))return!0;const l=i("GET_MAX_FILE_SIZE");if(null!==l&&e.size>=l)return!1;const E=i("GET_MIN_FILE_SIZE");return!(null!==E&&e.size<=E)}),e("LOAD_FILE",(e,{query:i})=>new Promise((l,I)=>{if(!i("GET_ALLOW_FILE_SIZE_VALIDATION"))return l(e);const t=i("GET_FILE_VALIDATE_SIZE_FILTER");if(t&&!t(e))return l(e);const n=i("GET_MAX_FILE_SIZE");if(null!==n&&e.size>=n)return void I({status:{main:i("GET_LABEL_MAX_FILE_SIZE_EXCEEDED"),sub:E(i("GET_LABEL_MAX_FILE_SIZE"),{filesize:_(n)})}});const s=i("GET_MIN_FILE_SIZE");if(null!==s&&e.size<=s)return void I({status:{main:i("GET_LABEL_MIN_FILE_SIZE_EXCEEDED"),sub:E(i("GET_LABEL_MIN_FILE_SIZE"),{filesize:_(s)})}});const L=i("GET_MAX_TOTAL_FILE_SIZE");if(null!==L){if(i("GET_ACTIVE_ITEMS").reduce((e,i)=>e+i.fileSize,0)>L)return void I({status:{main:i("GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED"),sub:E(i("GET_LABEL_MAX_TOTAL_FILE_SIZE"),{filesize:_(L)})}})}l(e)})),{options:{allowFileSizeValidation:[!0,l.BOOLEAN],maxFileSize:[null,l.INT],minFileSize:[null,l.INT],maxTotalFileSize:[null,l.INT],fileValidateSizeFilter:[null,l.FUNCTION],labelMinFileSizeExceeded:["File is too small",l.STRING],labelMinFileSize:["Minimum file size is {filesize}",l.STRING],labelMaxFileSizeExceeded:["File is too large",l.STRING],labelMaxFileSize:["Maximum file size is {filesize}",l.STRING],labelMaxTotalFileSizeExceeded:["Maximum total size exceeded",l.STRING],labelMaxTotalFileSize:["Maximum total file size is {filesize}",l.STRING]}}};"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:e}));export default e; |
/*! | ||
* FilePondPluginFileValidateSize 2.1.3 | ||
* FilePondPluginFileValidateSize 2.2.0 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -55,6 +55,11 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) { | ||
resolve(file); | ||
return; | ||
return resolve(file); | ||
} | ||
// check if file should be filtered | ||
var fileFilter = query('GET_FILE_VALIDATE_SIZE_FILTER'); | ||
if (fileFilter && !fileFilter(file)) { | ||
return resolve(file); | ||
} | ||
// reject or resolve based on file size | ||
@@ -137,2 +142,5 @@ var sizeMax = query('GET_MAX_FILE_SIZE'); | ||
// Filter the files that need to be validated for size | ||
fileValidateSizeFilter: [null, Type.FUNCTION], | ||
// error labels | ||
@@ -139,0 +147,0 @@ labelMinFileSizeExceeded: ['File is too small', Type.STRING], |
/*! | ||
* FilePondPluginFileValidateSize 2.1.3 | ||
* FilePondPluginFileValidateSize 2.2.0 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -9,2 +9,2 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(e=e||self).FilePondPluginFileValidateSize=i()}(this,function(){"use strict";var e=function(e){var i=e.addFilter,l=e.utils,E=l.Type,n=l.replaceInString,_=l.toNaturalFileSize;return i("ALLOW_HOPPER_ITEM",function(e,i){var l=i.query;if(!l("GET_ALLOW_FILE_SIZE_VALIDATION"))return!0;var E=l("GET_MAX_FILE_SIZE");if(null!==E&&e.size>=E)return!1;var n=l("GET_MIN_FILE_SIZE");return!(null!==n&&e.size<=n)}),i("LOAD_FILE",function(e,i){var l=i.query;return new Promise(function(i,E){if(l("GET_ALLOW_FILE_SIZE_VALIDATION")){var t=l("GET_MAX_FILE_SIZE");if(null!==t&&e.size>=t)E({status:{main:l("GET_LABEL_MAX_FILE_SIZE_EXCEEDED"),sub:n(l("GET_LABEL_MAX_FILE_SIZE"),{filesize:_(t)})}});else{var a=l("GET_MIN_FILE_SIZE");if(null!==a&&e.size<=a)E({status:{main:l("GET_LABEL_MIN_FILE_SIZE_EXCEEDED"),sub:n(l("GET_LABEL_MIN_FILE_SIZE"),{filesize:_(a)})}});else{var u=l("GET_MAX_TOTAL_FILE_SIZE");if(null!==u)if(l("GET_ACTIVE_ITEMS").reduce(function(e,i){return e+i.fileSize},0)>u)return void E({status:{main:l("GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED"),sub:n(l("GET_LABEL_MAX_TOTAL_FILE_SIZE"),{filesize:_(u)})}});i(e)}}}else i(e)})}),{options:{allowFileSizeValidation:[!0,E.BOOLEAN],maxFileSize:[null,E.INT],minFileSize:[null,E.INT],maxTotalFileSize:[null,E.INT],labelMinFileSizeExceeded:["File is too small",E.STRING],labelMinFileSize:["Minimum file size is {filesize}",E.STRING],labelMaxFileSizeExceeded:["File is too large",E.STRING],labelMaxFileSize:["Maximum file size is {filesize}",E.STRING],labelMaxTotalFileSizeExceeded:["Maximum total size exceeded",E.STRING],labelMaxTotalFileSize:["Maximum total file size is {filesize}",E.STRING]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:e})),e}); | ||
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(e=e||self).FilePondPluginFileValidateSize=i()}(this,function(){"use strict";var e=function(e){var i=e.addFilter,l=e.utils,E=l.Type,n=l.replaceInString,_=l.toNaturalFileSize;return i("ALLOW_HOPPER_ITEM",function(e,i){var l=i.query;if(!l("GET_ALLOW_FILE_SIZE_VALIDATION"))return!0;var E=l("GET_MAX_FILE_SIZE");if(null!==E&&e.size>=E)return!1;var n=l("GET_MIN_FILE_SIZE");return!(null!==n&&e.size<=n)}),i("LOAD_FILE",function(e,i){var l=i.query;return new Promise(function(i,E){if(!l("GET_ALLOW_FILE_SIZE_VALIDATION"))return i(e);var t=l("GET_FILE_VALIDATE_SIZE_FILTER");if(t&&!t(e))return i(e);var a=l("GET_MAX_FILE_SIZE");if(null!==a&&e.size>=a)E({status:{main:l("GET_LABEL_MAX_FILE_SIZE_EXCEEDED"),sub:n(l("GET_LABEL_MAX_FILE_SIZE"),{filesize:_(a)})}});else{var I=l("GET_MIN_FILE_SIZE");if(null!==I&&e.size<=I)E({status:{main:l("GET_LABEL_MIN_FILE_SIZE_EXCEEDED"),sub:n(l("GET_LABEL_MIN_FILE_SIZE"),{filesize:_(I)})}});else{var u=l("GET_MAX_TOTAL_FILE_SIZE");if(null!==u)if(l("GET_ACTIVE_ITEMS").reduce(function(e,i){return e+i.fileSize},0)>u)return void E({status:{main:l("GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED"),sub:n(l("GET_LABEL_MAX_TOTAL_FILE_SIZE"),{filesize:_(u)})}});i(e)}}})}),{options:{allowFileSizeValidation:[!0,E.BOOLEAN],maxFileSize:[null,E.INT],minFileSize:[null,E.INT],maxTotalFileSize:[null,E.INT],fileValidateSizeFilter:[null,E.FUNCTION],labelMinFileSizeExceeded:["File is too small",E.STRING],labelMinFileSize:["Minimum file size is {filesize}",E.STRING],labelMaxFileSizeExceeded:["File is too large",E.STRING],labelMaxFileSize:["Maximum file size is {filesize}",E.STRING],labelMaxTotalFileSizeExceeded:["Maximum total size exceeded",E.STRING],labelMaxTotalFileSize:["Maximum total file size is {filesize}",E.STRING]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:e})),e}); |
{ | ||
"name": "filepond-plugin-file-validate-size", | ||
"version": "2.1.3", | ||
"version": "2.2.0", | ||
"description": "File Size Validation Plugin for FilePond", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16675
302