Skip to content

Commit fd67f94

Browse files
committed
add options validation
1 parent d8bd8aa commit fd67f94

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/Config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,35 @@ export class Config {
494494
} else if (!Array.isArray(fileUpload.fileExtensions)) {
495495
throw 'fileUpload.fileExtensions must be an array.';
496496
}
497+
if (fileUpload.uriSourceEnabled === undefined) {
498+
fileUpload.uriSourceEnabled = FileUploadOptions.uriSourceEnabled.default;
499+
} else if (typeof fileUpload.uriSourceEnabled !== 'boolean') {
500+
throw 'fileUpload.uriSourceEnabled must be a boolean value.';
501+
}
502+
if (fileUpload.uriSourceRegex === undefined) {
503+
fileUpload.uriSourceRegex = FileUploadOptions.uriSourceRegex.default;
504+
} else if (typeof fileUpload.uriSourceRegex !== 'string') {
505+
throw 'fileUpload.uriSourceRegex must be a string.';
506+
}
507+
if (fileUpload.uriSourceIpsAllowed === undefined) {
508+
fileUpload.uriSourceIpsAllowed = FileUploadOptions.uriSourceIpsAllowed.default;
509+
} else if (!Array.isArray(fileUpload.uriSourceIpsAllowed)) {
510+
throw 'fileUpload.uriSourceIpsAllowed must be an array.';
511+
} else {
512+
this.validateIps('fileUpload.uriSourceIpsAllowed', fileUpload.uriSourceIpsAllowed);
513+
}
514+
if (fileUpload.uriSourceIpsDenied === undefined) {
515+
fileUpload.uriSourceIpsDenied = FileUploadOptions.uriSourceIpsDenied.default;
516+
} else if (!Array.isArray(fileUpload.uriSourceIpsDenied)) {
517+
throw 'fileUpload.uriSourceIpsDenied must be an array.';
518+
} else {
519+
this.validateIps('fileUpload.uriSourceIpsDenied', fileUpload.uriSourceIpsDenied);
520+
}
521+
if (fileUpload.uriSourceTimeout === undefined) {
522+
fileUpload.uriSourceTimeout = FileUploadOptions.uriSourceTimeout.default;
523+
} else if (typeof fileUpload.uriSourceTimeout !== 'number' || fileUpload.uriSourceTimeout <= 0) {
524+
throw 'fileUpload.uriSourceTimeout must be a positive number.';
525+
}
497526
}
498527

499528
static validateIps(field, masterKeyIps) {

0 commit comments

Comments
 (0)