21 lines
524 B
Go
21 lines
524 B
Go
package validator
|
|
|
|
import (
|
|
"pkg.local/validate"
|
|
)
|
|
|
|
type ProductItemsValidator struct {
|
|
Name string `validate:"max=256"`
|
|
Page uint32 `validate:"omitempty,min=1"`
|
|
PageSize uint32 `validate:"omitempty,min=1,max=100"`
|
|
}
|
|
|
|
func (p ProductItemsValidator) GetMessage() validate.ValidatorMessages {
|
|
return validate.ValidatorMessages{
|
|
"Name.max": "产品名长度不能超过256",
|
|
"Page.min": "页码最小为1",
|
|
"PageSize.min": "每页数量最小为1",
|
|
"PageSize.max": "每页数量最大为100",
|
|
}
|
|
}
|