-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add validate to command/query level
- Loading branch information
Alan-maqing
committed
Aug 30, 2023
1 parent
747477b
commit 71e09a4
Showing
4 changed files
with
24 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
..._read_service/internal/products/features/searching_products/v1/queries/search_products.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
package queries | ||
|
||
import "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" | ||
import ( | ||
validation "github.com/go-ozzo/ozzo-validation" | ||
"github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" | ||
) | ||
|
||
type SearchProducts struct { | ||
SearchText string `validate:"required"` | ||
*utils.ListQuery | ||
} | ||
|
||
func (s *SearchProducts) Validate() error { | ||
return validation.ValidateStruct(s, validation.Field(&s.SearchText, validation.Required)) | ||
} |