コード例 #1
0
ファイル: email_test.go プロジェクト: superduper/gova
func TestEmailInValid(t *testing.T) {
	v := struct {
		Email string `email:"-"`
	}{
		"fuga",
	}

	if err := gova.Validate(v); err == nil {
		t.Error("email validator doesn't work!")
	}
}
コード例 #2
0
ファイル: email_test.go プロジェクト: superduper/gova
func TestEmailValid(t *testing.T) {
	v := struct {
		Email string `email:"-"`
	}{
		"*****@*****.**",
	}

	if err := gova.Validate(v); err != nil {
		t.Error(err)
	}
}
コード例 #3
0
ファイル: pattern_test.go プロジェクト: superduper/gova
func TestPatternValid(t *testing.T) {
	v := struct {
		Num string `pattern:"[0-9]+"`
	}{
		"11111",
	}

	if err := gova.Validate(v); err != nil {
		t.Error(err)
	}
}
コード例 #4
0
ファイル: pattern_test.go プロジェクト: superduper/gova
func TestPatternInValid(t *testing.T) {
	v := struct {
		Num string `pattern:"[0-9]+"`
	}{
		"fuga",
	}

	if err := gova.Validate(v); err == nil {
		t.Error("pattern validator doesn't work!")
	}
}
コード例 #5
0
ファイル: length_test.go プロジェクト: superduper/gova
func TestLengthValid(t *testing.T) {
	v := struct {
		Str string `length:"10"`
	}{
		"1234567890",
	}

	if err := gova.Validate(v); err != nil {
		t.Error(err)
	}
}
コード例 #6
0
ファイル: length_test.go プロジェクト: superduper/gova
func TestLengthInValid(t *testing.T) {
	v := struct {
		Str string `length:"10"`
	}{
		"1234",
	}

	if err := gova.Validate(v); err == nil {
		t.Error("length validator doesn't work!")
	}
}
コード例 #7
0
ファイル: reflect_test.go プロジェクト: superduper/gova
func TestStructPointerResolutionValidation(t *testing.T) {
	// this test should not cause panic
	tmp := &Form{"alpha"}
	gova.Validate(tmp)
}