MCPcopy Index your code
hub / github.com/dreamsofcode-io/zenstats / Validate

Method Validate

internal/config/database.go:111–137  ·  view source on GitHub ↗

Validate checks a Database configuration to ensure it's values are valid for connecting to a database.

()

Source from the content-addressed store, hash-verified

109// Validate checks a Database configuration to ensure it's values are
110// valid for connecting to a database.
111func (c *Database) Validate() error {
112 if c.DBName == "" {
113 return fmt.Errorf("invalid database name")
114 }
115
116 if c.Host == "" {
117 return fmt.Errorf("invalid host")
118 }
119
120 if c.Username == "" {
121 return fmt.Errorf("invalid username")
122 }
123
124 if c.Password == "" {
125 return fmt.Errorf("invalid password")
126 }
127
128 if c.Port == 0 {
129 return fmt.Errorf("invalid port")
130 }
131
132 if c.SSLMode == "" {
133 return fmt.Errorf("invalid sslmode")
134 }
135
136 return nil
137}

Callers 2

NewDatabaseFunction · 0.95
TestConfigValidationFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestConfigValidationFunction · 0.76