File size
Validate min and max sizes of uploaded files.
Installation
This requirement is available by default and does not require installation.
Usage
import {RequirementFileSize} from "@farbor/server";
export default {
assets: {
image: {
requirements: [
new RequirementFileSize({end: 5_000_000}) // max 5 mb
// new RequirementFileSize({start: 1_000, end: 5_000_000}) // max 5 mb at least 1 kb
// new RequirementFileSize({start: 1_000}) // at least 1 kb - no max - dangerous!
]
}
}
}
JSON representation
OPTIONS /image
{
"collection": "image",
"requirementList": [
{
"type": "fileSize",
"fileSize": {
"end": {
"asString": "5 MB",
"inBytes": 5242880,
"unit": "MB",
"value": 5
}
}
}
]
}