From c0b1802849cca403a780e1ce136e332262a89ee3 Mon Sep 17 00:00:00 2001 From: Aldino Kemal Date: Thu, 10 Feb 2022 12:28:03 +0700 Subject: [PATCH] feat: add validation image (send image api) --- validations/send_validation.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/validations/send_validation.go b/validations/send_validation.go index 33d6d68..807c19a 100644 --- a/validations/send_validation.go +++ b/validations/send_validation.go @@ -41,4 +41,17 @@ func ValidateSendImage(request structs.SendImageRequest) { Message: "this is only work for indonesia country (start with 62)", }) } + + availableMimes := map[string]bool{ + "image/jpeg": true, + "image/jpg": true, + "image/png": true, + } + + if !availableMimes[request.Image.Header.Get("Content-Type")] { + panic(utils.ValidationError{ + Message: "your image is not allowed. please use jpg/jpeg/png", + }) + } + }