func (R *Reply) Validate() (isValid bool, msg string) { isValid, msg = validation.RequireNotEmpty(R.Content) if isValid == false { goto ReturnPart } isValid, msg = validation.RequireNotEmpty(R.Name) if isValid == false { goto ReturnPart } ReturnPart: return }
func Test_RequireNotEmpty(t *testing.T) { input := " not empty text " passed, msg := validation.RequireNotEmpty(input) if passed == false || msg != "" { t.Fail() } emptyinput := " " passed, msg = validation.RequireNotEmpty(emptyinput) if passed == true || msg == "" { t.Fail() } }
func (M *Main) Validate() (isValid bool, msg string) { isValid, msg = validation.RequireNotEmpty(M.Content) if isValid == false { goto ReturnPart } isValid, msg = validation.RequireNotEmpty(M.Name) if isValid == false { goto ReturnPart } isValid, msg = validation.RequireNotEmpty(M.Category) if isValid == false { goto ReturnPart } ReturnPart: return }