Home / Function/ TestValidatorEngine() — gin Function Reference

TestValidatorEngine() — gin Function Reference

Architecture documentation for the TestValidatorEngine() function in validate_test.go from the gin codebase.

Entity Profile

Relationship Graph

Source Code

binding/validate_test.go lines 234–253

func TestValidatorEngine(t *testing.T) {
	// This validates that the function `notOne` matches
	// the expected function signature by `defaultValidator`
	// and by extension the validator library.
	engine, ok := Validator.Engine().(*validator.Validate)
	assert.True(t, ok)

	err := engine.RegisterValidation("notone", notOne)
	// Check that we can register custom validation without error
	require.NoError(t, err)

	// Create an instance which will fail validation
	withOne := structCustomValidation{Integer: 1}
	errs := validate(withOne)

	// Check that we got back non-nil errs
	require.Error(t, errs)
	// Check that the error matches expectation
	require.Error(t, errs, "notone")
}

Domain

Subdomains

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free