Pure functional file validation logic.
This namespace contains no side effects - only pure functions for validating files based on size, type, extension, etc.
Pure functional file validation logic. This namespace contains no side effects - only pure functions for validating files based on size, type, extension, etc.
Common MIME type mappings for file extensions.
Common MIME type mappings for file extensions.
Default maximum file size in bytes (10 MB).
Default maximum file size in bytes (10 MB).
(extension-matches-mime-type? filename content-type)Check if file extension matches the declared MIME type.
Check if file extension matches the declared MIME type.
(generate-unique-filename* original-filename unique-suffix)Generate a unique filename using explicit shell-supplied components.
Preserves the original extension.
Generate a unique filename using explicit shell-supplied components. Preserves the original extension.
(get-file-extension filename)Extract file extension from filename.
Returns lowercase extension without the dot, or nil if no extension.
Extract file extension from filename. Returns lowercase extension without the dot, or nil if no extension.
(is-image-mime-type? content-type)Check if content type is an image MIME type.
Check if content type is an image MIME type.
(mime-type-from-extension filename)Get MIME type from file extension.
Get MIME type from file extension.
(sanitize-filename filename)Sanitize filename to remove potentially dangerous characters.
Sanitize filename to remove potentially dangerous characters. - Removes path separators - Removes special characters - Limits length - Preserves extension
(validate-content-type content-type allowed-types)Validate content type against allowed types.
Returns validation result map.
Validate content type against allowed types. Returns validation result map.
(validate-extension filename allowed-extensions)Validate file extension against allowed extensions.
Returns validation result map.
Validate file extension against allowed extensions. Returns validation result map.
(validate-file {:keys [bytes content-type size] :as _file-data}
{:keys [filename] :as _file-metadata}
{:keys [max-size allowed-types allowed-extensions] :as _options})Perform comprehensive file validation.
Parameters:
Returns validation result map with all errors if any.
Perform comprehensive file validation. Parameters: - file-data: Map with :bytes, :content-type, :size - file-metadata: Map with :filename - options: Map with :max-size, :allowed-types, :allowed-extensions Returns validation result map with all errors if any.
(validate-file-size file-size max-size)Validate file size against maximum allowed size.
Returns validation result map.
Validate file size against maximum allowed size. Returns validation result map.
(validate-image-file file-data file-metadata options)Validate a file as an image with additional image-specific checks.
Returns validation result map.
Validate a file as an image with additional image-specific checks. Returns validation result map.
(validate-image-type content-type)Validate that the file is an image based on MIME type.
Returns validation result map.
Validate that the file is an image based on MIME type. Returns validation result map.
(validation-failure error-message)(validation-failure error-code error-message)(validation-failure error-code error-message details)Create a failed validation result with error details.
Create a failed validation result with error details.
(validation-success)(validation-success data)Create a successful validation result.
Create a successful validation result.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |