Пример #1
0
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
}
Пример #2
0
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()
	}
}
Пример #3
0
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
}