validate inputs
This commit is contained in:
+11
-4
@@ -6,17 +6,21 @@ import (
|
||||
"gotemplate/internal/document"
|
||||
"gotemplate/internal/queue"
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type DocumentController struct {
|
||||
document document.Service
|
||||
validator *validator.Validate
|
||||
document document.Service
|
||||
}
|
||||
|
||||
func NewDocumentController(svc document.Service) *DocumentController {
|
||||
func NewDocumentController(svc document.Service, validator *validator.Validate) *DocumentController {
|
||||
return &DocumentController{
|
||||
document: svc,
|
||||
validator: validator,
|
||||
document: svc,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +35,10 @@ func (s *DocumentController) Sync(ctx context.Context, config *queue.QueueConfig
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO normalise input here
|
||||
err = s.validator.Struct(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = s.document.Sync(ctx, &body)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user