fix: ci dir error
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package validator
|
||||
|
||||
import "lone-services/pkg/validate"
|
||||
|
||||
type AdCreateValidator struct {
|
||||
Type uint32 `validate:"required,oneof=1 2 3 4"`
|
||||
Image string `validate:"required_without=Content,max=255"`
|
||||
Content string `validate:"required_without=Image,max=255"`
|
||||
Url string `validate:"max=255"`
|
||||
}
|
||||
|
||||
func (p AdCreateValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Type.required": "请选择类型",
|
||||
"Type.oneof": "类型不对",
|
||||
"Image.required_without": "图片与文本内容必须填写一个",
|
||||
"Content.required_without": "图片与文本内容必须填写一个",
|
||||
"Image.max": "图片长度不能超过255",
|
||||
"Content.max": "内容长度不能超过255",
|
||||
"Url.max": "链接长度不能超过255",
|
||||
}
|
||||
}
|
||||
|
||||
type AdEditValidator struct {
|
||||
Id int64 `validate:"required,gt=0"`
|
||||
Type uint32 `validate:"required,oneof=1 2 3 4"`
|
||||
Image string `validate:"required_without=Content,max=255"`
|
||||
Content string `validate:"required_without=Image,max=255"`
|
||||
Url string `validate:"max=255"`
|
||||
}
|
||||
|
||||
func (p AdEditValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Id.required": "ID不能为空",
|
||||
"Id.gt": "ID必须大于0",
|
||||
"Type.required": "请选择类型",
|
||||
"Type.oneof": "类型不对",
|
||||
"Image.required_without": "图片与文本内容必须填写一个",
|
||||
"Content.required_without": "图片与文本内容必须填写一个",
|
||||
"Image.max": "图片长度不能超过255",
|
||||
"Content.max": "内容长度不能超过255",
|
||||
"Url.max": "链接长度不能超过255",
|
||||
}
|
||||
}
|
||||
|
||||
type AdItemsValidator struct {
|
||||
Page uint32 `validate:"omitempty,min=1"`
|
||||
PageSize uint32 `validate:"omitempty,min=1,max=100"`
|
||||
}
|
||||
|
||||
func (p AdItemsValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Page.min": "页码最小为1",
|
||||
"PageSize.min": "每页数量最小为1",
|
||||
"PageSize.max": "每页数量最大为100",
|
||||
}
|
||||
}
|
||||
|
||||
type AdStatusValidator struct {
|
||||
Id int64 `validate:"required,gt=0"`
|
||||
Status uint32 `validate:"required,oneof=1 2"`
|
||||
Reason string `validate:"required_if=Status 2,max=255"`
|
||||
}
|
||||
|
||||
func (p AdStatusValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Id.required": "ID不能为空",
|
||||
"Id.gt": "ID必须大于0",
|
||||
"Status.required": "状态不能为空",
|
||||
"Status.oneof": "状态不对",
|
||||
"Reason.required_if": "禁用状态,理由不能为空",
|
||||
"Reason.max": "理由长度不能超过255",
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user