Refactored out detectFileMIMEType, matchesMIMEType logic for reuse. Added standalone isMIMEType validator for flexibility#1544
Conversation
|
PR #1 to refactor out the mime detection logic and create a flexible standalone isMIMEType Validator To keep existing behavior I've retained the type dict for isImage |
zemzale
left a comment
There was a problem hiding this comment.
One small tests thing, but the code looks good.
Would like someone else opinion about the validator itself, before merging.
…dded standalone isMIMEType validator for flexibility
5436636 to
4de0656
Compare
|
Hi @zemzale — I've rebased this branch on the latest Branch is now conflict-free and CI should run cleanly. The |
Summary
Adds a new built-in
mimetypevalidator for file paths.It supports both exact MIME matches and wildcard subtype matches:
Changes
mimetypeas a built-in validation tagisImageto reuse the shared MIME detection helperisImage's existing explicit image MIME allowlist unchangedmimetypemimetypeNotes
mimetypeaccepts:type/subtypetype/*Validation fails if the field is not a string, the file does not exist, the path is a directory, the MIME type cannot be detected, or the validator param is invalid.
Make sure that you've checked the boxes below before you submit PR:
@go-playground/validator-maintainers