unos/illust-data/illust/illust_validator.go

28 lines
749 B
Go
Raw Normal View History

2024-03-17 06:58:19 +00:00
package illust
import validation "github.com/go-ozzo/ozzo-validation"
type IllustValidator struct {
}
func (iv *IllustValidator) Validate(i interface{}) error {
if c, ok := i.(validation.Validatable); ok {
return c.Validate()
}
return nil
}
func (i Illust) Validate() error {
return validation.ValidateStruct(
&i,
validation.Field(&i.Id, validation.Required),
validation.Field(&i.Name, validation.Required),
validation.Field(&i.Sha256, validation.Required),
validation.Field(&i.S3Id, validation.Required),
validation.Field(&i.Tags, validation.Required),
validation.Field(&i.Originals, validation.Required),
validation.Field(&i.Characters, validation.Required),
validation.Field(&i.Description, validation.Required),
)
}