refac: allowed image types and the size limit are a domain rule checked by the use case, not by the persistence layer
This commit is contained in:
1 parent
8a8a24434a
commit
5992c8598b
7 files changed
+249
-17
No files matched your search
@@ -13,5 +13,11 @@ func NewCreateImageUseCase(imageRepository image.Repository) *CreateImageUseCase
|
||||
}
|
||||
|
||||
func (g *CreateImageUseCase) CreateImage(input image.ImageInput) (image.Image, error) {
|
||||
if !image.IsAllowedContentType(input.ContentType) {
|
||||
return image.Image{}, image.ErrImageTypeNotAllowed
|
||||
}
|
||||
if input.Size > image.MaxImageSize {
|
||||
return image.Image{}, image.ErrImageTooLarge
|
||||
}
|
||||
return g.imageRepository.Create(input)
|
||||
}
|
||||
Reference in new issue
Block a user