@@ -79,7 +79,7 @@ type QuestionAdd struct {
7979 // question title
8080 Title string `validate:"required,notblank,gte=6,lte=150" json:"title"`
8181 // content
82- Content string `validate:"required,notblank, gte=6 ,lte=65535" json:"content"`
82+ Content string `validate:"gte=0 ,lte=65535" json:"content"`
8383 // html
8484 HTML string `json:"-"`
8585 // tags
@@ -100,20 +100,14 @@ func (req *QuestionAdd) Check() (errFields []*validator.FormErrorField, err erro
100100 tag .ParsedText = converter .Markdown2HTML (tag .OriginalText )
101101 }
102102 }
103- if req .HTML == "" {
104- return append (errFields , & validator.FormErrorField {
105- ErrorField : "content" ,
106- ErrorMsg : reason .QuestionContentCannotEmpty ,
107- }), errors .BadRequest (reason .QuestionContentCannotEmpty )
108- }
109103 return nil , nil
110104}
111105
112106type QuestionAddByAnswer struct {
113107 // question title
114108 Title string `validate:"required,notblank,gte=6,lte=150" json:"title"`
115109 // content
116- Content string `validate:"required,notblank, gte=6 ,lte=65535" json:"content"`
110+ Content string `validate:"gte=0 ,lte=65535" json:"content"`
117111 // html
118112 HTML string `json:"-"`
119113 AnswerContent string `validate:"required,notblank,gte=6,lte=65535" json:"answer_content"`
@@ -138,19 +132,11 @@ func (req *QuestionAddByAnswer) Check() (errFields []*validator.FormErrorField,
138132 tag .ParsedText = converter .Markdown2HTML (tag .OriginalText )
139133 }
140134 }
141- if req .HTML == "" {
142- errFields = append (errFields , & validator.FormErrorField {
143- ErrorField : "content" ,
144- ErrorMsg : reason .QuestionContentCannotEmpty ,
145- })
146- }
147135 if req .AnswerHTML == "" {
148136 errFields = append (errFields , & validator.FormErrorField {
149137 ErrorField : "answer_content" ,
150138 ErrorMsg : reason .AnswerContentCannotEmpty ,
151139 })
152- }
153- if req .HTML == "" || req .AnswerHTML == "" {
154140 return errFields , errors .BadRequest (reason .QuestionContentCannotEmpty )
155141 }
156142 return nil , nil
@@ -195,7 +181,7 @@ type QuestionUpdate struct {
195181 // question title
196182 Title string `validate:"required,notblank,gte=6,lte=150" json:"title"`
197183 // content
198- Content string `validate:"required,notblank, gte=6 ,lte=65535" json:"content"`
184+ Content string `validate:"gte=0 ,lte=65535" json:"content"`
199185 // html
200186 HTML string `json:"-"`
201187 InviteUser []string `validate:"omitempty" json:"invite_user"`
@@ -227,12 +213,6 @@ type QuestionUpdateInviteUser struct {
227213
228214func (req * QuestionUpdate ) Check () (errFields []* validator.FormErrorField , err error ) {
229215 req .HTML = converter .Markdown2HTML (req .Content )
230- if req .HTML == "" {
231- return append (errFields , & validator.FormErrorField {
232- ErrorField : "content" ,
233- ErrorMsg : reason .QuestionContentCannotEmpty ,
234- }), errors .BadRequest (reason .QuestionContentCannotEmpty )
235- }
236216 return nil , nil
237217}
238218
0 commit comments