Custom validation: Overview
Custom validation lets you enforce your own business rules during file selection and upload. You can validate single files or the entire collection and tailor the flow to your product needs.
You decide the rules—implement what “valid” means for your use case.
Choose the scope
- File validators — validate each file independently (type, size, dimensions, metadata, content heuristics). See: File validators
- Collection validators — validate the whole selection (min/max count, required mixes, duplicates, cross-file rules). See: Collection validators
Common use cases
Here are example scenarios where custom validation helps implement product-specific logic:
File-level
- Enforce allowed aspect ratios (e.g., only 16:9 or 1:1) or minimum megapixels for creative assets.
- Require specific filename patterns or metadata (e.g., SKU in the filename, required EXIF tags).
- Gate uploads based on content signals for a single item (e.g., block NSFW-flagged assets if you propagate those flags to entries).
- Verify document heuristics (e.g., PDF page count within range; spreadsheet must contain a required sheet name).
Collection-level
- Prevent duplicates within the current selection by comparing names, sizes, or content hashes.
- Cross-file requirements (e.g., exactly one cover image plus at least three gallery images; one CSV plus its corresponding README).
Where results appear
- UI: Custom validator messages are shown to users in the uploader.
- Events and API: The same errors are available via uploader events and the Uploader API. See: Events and Uploader API.