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

Dependency Diagram

graph TD
  d4982062_3ecc_6d54_ff6f_cf5e0ceeaffe["TestValidatorEngine()"]
  7e10d9ab_ee22_270a_45bf_aa404c229204["validate_test.go"]
  d4982062_3ecc_6d54_ff6f_cf5e0ceeaffe -->|defined in| 7e10d9ab_ee22_270a_45bf_aa404c229204
  style d4982062_3ecc_6d54_ff6f_cf5e0ceeaffe fill:#6366f1,stroke:#818cf8,color:#fff

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")
}

Subdomains

Frequently Asked Questions

What does TestValidatorEngine() do?
TestValidatorEngine() is a function in the gin codebase, defined in binding/validate_test.go.
Where is TestValidatorEngine() defined?
TestValidatorEngine() is defined in binding/validate_test.go at line 234.

Analyze Your Own Codebase

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

Try Supermodel Free