express-image-validator
Version:
Validator of various image parameters in Express.js applications
22 lines (21 loc) • 741 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateLimit = void 0;
const limit_1 = require("./errors/limit");
/**
* Checks that the number of uploaded files does not exceed the `limit`.
* @type { FieldValidatorFunction }
* @param { string } field Field name.
* @param { UploadedFile[] } files Array of uploaded files.
* @param { ValidationOptions } options Validation options.
* @returns { ValidationResult }
*/
const validateLimit = (field, files, { limit }) => {
if (limit && files.length > limit) {
return {
errors: [(0, limit_1.exceededLimitError)(field, files.length, limit)],
};
}
return { errors: [] };
};
exports.validateLimit = validateLimit;