"files[]?": type("File | File[] < 6").narrow((data, ctx) => {
const MAX_SIZE = 4 * 1024 * 1024;
if (Array.isArray(data)) {
const totalSize = data.reduce((sum, file) => sum + file.size, 0);
if (totalSize > MAX_SIZE) {
return ctx.reject({
message: `Total files size should be less than 4MB (actual: ${(totalSize/1024/1024).toFixed(2)}MB)`,
actual: `${data.length} files, ${totalSize} bytes total`,
});
}
return true;
}
if (data.size > MAX_SIZE) {
return ctx.reject({
message: "File size should be less than 4MB",
actual: `${(data.size/1024/1024).toFixed(2)}MB`,
});
}
return true;
}),
"files[]?": type("File | File[] < 6").narrow((data, ctx) => {
const MAX_SIZE = 4 * 1024 * 1024;
if (Array.isArray(data)) {
const totalSize = data.reduce((sum, file) => sum + file.size, 0);
if (totalSize > MAX_SIZE) {
return ctx.reject({
message: `Total files size should be less than 4MB (actual: ${(totalSize/1024/1024).toFixed(2)}MB)`,
actual: `${data.length} files, ${totalSize} bytes total`,
});
}
return true;
}
if (data.size > MAX_SIZE) {
return ctx.reject({
message: "File size should be less than 4MB",
actual: `${(data.size/1024/1024).toFixed(2)}MB`,
});
}
return true;
}),