From ad9124ef41ef97142011e63c781e19f3443e5c62 Mon Sep 17 00:00:00 2001 From: SoXX Date: Fri, 5 Jul 2024 14:06:39 +0200 Subject: [PATCH] fix: reverse validation Signed-off-by: SoXX --- internal/postgres/post.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/postgres/post.go b/internal/postgres/post.go index aaf2d63..b618b04 100644 --- a/internal/postgres/post.go +++ b/internal/postgres/post.go @@ -3,6 +3,7 @@ package postgres import ( "context" "errors" + otterError "git.dragse.it/anthrove/otter-space-sdk/v2/pkg/error" "git.dragse.it/anthrove/otter-space-sdk/v2/pkg/models" @@ -38,14 +39,14 @@ func CreatePost(ctx context.Context, db *gorm.DB, anthrovePost *models.Post) err // TODO: Make Tests func CreatePostInBatch(ctx context.Context, db *gorm.DB, anthrovePost []models.Post, batchSize int) error { - if len(anthrovePost) == 0 { - return &otterError.EntityValidationFailed{Reason: "anthrovePost cannot be empty"} - } - if anthrovePost == nil { return &otterError.EntityValidationFailed{Reason: "anthrovePost cannot be nil"} } + if len(anthrovePost) == 0 { + return &otterError.EntityValidationFailed{Reason: "anthrovePost cannot be empty"} + } + if batchSize == 0 { return &otterError.EntityValidationFailed{Reason: "batch size cannot be zero"} }