mirror of
https://github.com/3ybactuk/marketplace-go-service-project.git
synced 2025-10-30 14:03:45 +03:00
[hw-8] add: comment service
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Comment struct {
|
||||
ID int64 `validate:"gt=0"`
|
||||
UserID int64 `validate:"gt=0"`
|
||||
SKU int64 `validate:"gt=0"`
|
||||
CreatedAt time.Time
|
||||
Text string `validate:"lte=255,gt=0"`
|
||||
}
|
||||
|
||||
func (c *Comment) Validate() error {
|
||||
if err := validate.Struct(c); err != nil {
|
||||
return fmt.Errorf("invalid requested values: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -3,3 +3,5 @@ package model
|
||||
import "errors"
|
||||
|
||||
var ErrCommentNotFound = errors.New("comment not found")
|
||||
var ErrCommentEditUserMismatch = errors.New("comment edit user mismatch")
|
||||
var ErrCommentEditTimeout = errors.New("comment edit timeout")
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package model
|
||||
|
||||
import "github.com/go-playground/validator/v10"
|
||||
|
||||
var validate *validator.Validate
|
||||
|
||||
func init() {
|
||||
validate = validator.New()
|
||||
}
|
||||
Reference in New Issue
Block a user