mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-03-17 23:17:09 -04:00
Introduce input validation for ValueService.GetValueByUniqueIdentifiers
This commit is contained in:
@@ -216,8 +216,11 @@ func (g Service) GetValue(c context.Context, req *proto.GetValueRequest, res *pr
|
||||
}
|
||||
|
||||
// GetValueByUniqueIdentifiers implements the ValueService interface
|
||||
func (g Service) GetValueByUniqueIdentifiers(ctx context.Context, in *proto.GetValueByUniqueIdentifiersRequest, res *proto.GetValueResponse) error {
|
||||
v, err := g.manager.ReadValueByUniqueIdentifiers(in.AccountUuid, in.SettingId)
|
||||
func (g Service) GetValueByUniqueIdentifiers(ctx context.Context, req *proto.GetValueByUniqueIdentifiersRequest, res *proto.GetValueResponse) error {
|
||||
if validationError := validateGetValueByUniqueIdentifiers(req); validationError != nil {
|
||||
return merrors.BadRequest(g.id, "%s", validationError)
|
||||
}
|
||||
v, err := g.manager.ReadValueByUniqueIdentifiers(req.AccountUuid, req.SettingId)
|
||||
if err != nil {
|
||||
return merrors.NotFound(g.id, "%s", err)
|
||||
}
|
||||
|
||||
@@ -91,6 +91,14 @@ func validateGetValue(req *proto.GetValueRequest) error {
|
||||
return validation.Validate(req.Id, is.UUID)
|
||||
}
|
||||
|
||||
func validateGetValueByUniqueIdentifiers(req *proto.GetValueByUniqueIdentifiersRequest) error {
|
||||
return validation.ValidateStruct(
|
||||
req,
|
||||
validation.Field(&req.SettingId, is.UUID),
|
||||
validation.Field(&req.AccountUuid, requireAccountID...),
|
||||
)
|
||||
}
|
||||
|
||||
func validateListValues(req *proto.ListValuesRequest) error {
|
||||
return validation.ValidateStruct(
|
||||
req,
|
||||
|
||||
Reference in New Issue
Block a user