You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
449 B
18 lines
449 B
package messagelog
|
|
|
|
import "gopkg.in/validator.v2"
|
|
|
|
type Message struct {
|
|
Index int `json:"index"`
|
|
Sender string `json:"sender" validate:"min=1"`
|
|
ContentType string `json:"content_type" validate:"min=1"`
|
|
Content interface{} `json:"content" validate:"nonnil"`
|
|
}
|
|
|
|
func (m Message) validate() error {
|
|
if err := validator.Validate(m); err != nil {
|
|
return &ErrInvalidMessage{message: err.Error()}
|
|
}
|
|
return nil
|
|
}
|